Tapas Kumar Ghosh has Published 226 Articles

Design a queue data structure to get minimum or maximum in O(1) time

Tapas Kumar Ghosh

Tapas Kumar Ghosh

Updated on 04-Jun-2025 17:48:39

895 Views

In data structure & algorithm, we have a deque header file that handles the properties of stack and queue. For getting minimum and maximum value from O(1) time complexity, we need constant time. So, deque is one of the possible advantages of using both stack and queue. O(1) Time Complexity ... Read More

What is the correct way to use printf to print a size_t in C/C++?

Tapas Kumar Ghosh

Tapas Kumar Ghosh

Updated on 04-Jun-2025 17:41:51

25K+ Views

We should use "%zu" to print the variables of size_t length. We can use "%d" also to print size_t variables, it may not always produce an error. The correct way to print size_t variables is use of "%zu", because compiler standard %zu is defined as a format specifier for this ... Read More

exit(), abort() and assert() in C/C++

Tapas Kumar Ghosh

Tapas Kumar Ghosh

Updated on 04-Jun-2025 17:30:39

2K+ Views

In C and C++ programming, the exit(), abort(), and assert() functions are used for program termination and debugging. Each of these functions have different purpose and defined in different header files. In this article, we will learn these functions and their usage with the help of examples. The exit() Function ... Read More

What all is inherited from parent class in C++?

Tapas Kumar Ghosh

Tapas Kumar Ghosh

Updated on 04-Jun-2025 14:22:42

4K+ Views

In C++, when a class inherits from another class, it inherits all members from parent class, but their accessibility are based on access specifiers. Key Points on What Inherits from Parent Class Following are some points on derived class inherits from its parent: The derived ... Read More

How do I convert a char to an int in C and C++?

Tapas Kumar Ghosh

Tapas Kumar Ghosh

Updated on 04-Jun-2025 14:12:57

24K+ Views

In C/C++, char represents a single character, whereas int is an integer that can store both positive and negative values, but not fractional or decimal values. If you are given a character and want to convert it into an integer, it is easy and can be achieved with the different approaches. ... Read More

Can main() be overloaded in C++?

Tapas Kumar Ghosh

Tapas Kumar Ghosh

Updated on 03-Jun-2025 14:17:49

800 Views

In every C/C++ program, execution starts from the main() function. Defining multiple main() functions will result in a compilation error. Can main() be Overloaded in C++? No, we cannot overload the main() function in C++ because main() serves as the entry point of any C++ program and must follow a ... Read More

Reading and writing binary file in C/C++

Tapas Kumar Ghosh

Tapas Kumar Ghosh

Updated on 03-Jun-2025 12:53:36

76K+ Views

Writing a Binary File To write a binary file in C/C++ use fwrite()/write() method. It is used to write a given number of bytes on the given stream, starting at the position of the "put" pointer. The file is extended if the put pointer is currently at the end of ... Read More

delete() and free() in C++

Tapas Kumar Ghosh

Tapas Kumar Ghosh

Updated on 03-Jun-2025 11:19:24

1K+ Views

In C++, both delete and free() are used to deallocate the dynamically created memory. In this article, we will learn about the delete operator and free() function with the help of examples. C++ delete Operator The delete operator is used to deallocate the memory. User has privilege to deallocate the ... Read More

How to catch all the exceptions in C++?

Tapas Kumar Ghosh

Tapas Kumar Ghosh

Updated on 02-Jun-2025 14:26:55

11K+ Views

Exceptions are problems that arise at the time of execution of a program. They are events that are thrown at runtime. They protect the code and allow the program to run even after an exception is thrown. Exception handling is used to handle the exceptions. Catching All Exceptions To ... Read More

C++ Program to Calculate Difference Between Two Time Period

Tapas Kumar Ghosh

Tapas Kumar Ghosh

Updated on 02-Jun-2025 14:19:25

2K+ Views

There are two time periods provided in the form of hours, minutes and seconds. Then their difference is calculated. For example: Time period 1 = 8:6:2 Time period 2 = 3:9:3 Time Difference is 4:56:59 C++ Program to Find Difference Between Two Times To find the time differences then ... Read More

Advertisements