Tapas Kumar Ghosh has Published 226 Articles

Difference Between int and long

Tapas Kumar Ghosh

Tapas Kumar Ghosh

Updated on 05-May-2025 18:35:59

7K+ Views

In programming, int and long are the part of primitive data type. The int stores the integer value while long stores the larger range of values like a whole number. In this article, we will see the differences between int and long data types. int (Integer) Data Type The keyword ... Read More

Left Shift and Right Shift Operators in C/C++

Tapas Kumar Ghosh

Tapas Kumar Ghosh

Updated on 02-May-2025 18:02:48

2K+ Views

Both the left shift and right shift are known as bitwise shift operators. These operators are useful for working with binary integers by shifting the bits to the left or right. Below is the mathematical representation of the left and right shift operators: // left shift operator x > n ... Read More

How to calculate Execution Time of a Code Snippet in C++?

Tapas Kumar Ghosh

Tapas Kumar Ghosh

Updated on 02-May-2025 18:01:54

2K+ Views

To calculate the execution time of a program, use the std::chrono library, which was introduced in C++11. This library has two distinct objects: time_point and duration. The time_point represents the variable names that store the start and end times of specific algorithms, functions, or loops used in the program. While ... Read More

Why are global variables bad in C/C++?

Tapas Kumar Ghosh

Tapas Kumar Ghosh

Updated on 02-May-2025 18:00:43

3K+ Views

Global variables are declared and defined outside any function in the program. They hold their values throughout the lifetime of the program and are accessible throughout its execution. When we use our non-constant global variable in our programs, it becomes harder to manage. So, it is better to use local ... Read More

C++ Program to Add Complex Numbers by Passing Structure to a Function

Tapas Kumar Ghosh

Tapas Kumar Ghosh

Updated on 02-May-2025 15:25:14

845 Views

Complex numbers are numbers that are expressed as a+bi, where i is an imaginary number and a and b, are real numbers. Some of the example of complex numbers are 2 + 5i, 3 - 9i, 8 + 2i, etc. How to add complex number? Here, we will explain how ... Read More

C++ Program to Perform Addition Operation Using Bitwise Operators

Tapas Kumar Ghosh

Tapas Kumar Ghosh

Updated on 30-Apr-2025 18:17:52

2K+ Views

Bitwise operators are used for representing binary integers, where the operator directly performs operations on the individual bits of integer values. To perform an addition operation using bitwise operators, use operators like AND, XOR, and NOT. The OR operator cannot perform addition on its own because, 1 | 1 results ... Read More

How can I convert string to double in C/C++?

Tapas Kumar Ghosh

Tapas Kumar Ghosh

Updated on 22-Apr-2025 18:26:45

1K+ Views

Given a string like "-27.89", we can convert it into a double value such as -27.890000. In this article, we use various approaches from C/C++ library functions to perform this string into double conversion: Using atof() Function Using strtod() Function Using stod() Function Using stringstream() Function String to ... Read More

Variable initialization in C++

Tapas Kumar Ghosh

Tapas Kumar Ghosh

Updated on 22-Apr-2025 15:17:33

9K+ Views

In C++, variables are name given by the user to store data. While datatype is used to declare and initialize a variable that allocates memory to that variable. There are various ways to initialize the data types such as int, char, float, etc. to allocate the memory to that variable. ... Read More

When to use extern in C/C++

Tapas Kumar Ghosh

Tapas Kumar Ghosh

Updated on 22-Apr-2025 15:15:40

11K+ Views

In C/C++, the extern keyword is used to declare a variable that is defined in another file or scope. It allows the program to access a variable or function that is defined outside the file. There are two main reason of using extern in C/C++ programs which is listed below: ... Read More

C++ Program to Find Fibonacci Numbers using Recursion

Tapas Kumar Ghosh

Tapas Kumar Ghosh

Updated on 21-Apr-2025 18:49:30

71K+ Views

The Fibonacci sequence is a sequence of numbers in which each number is the sum of the two numbers that precede it. ExampleBelow is the mathematical example to understand the logic of the Fibonacci number: Suppose, n = 3, then, F(0) = 0 F(1) = 1 F(2) = F(1) + ... Read More

Previous 1 ... 4 5 6 7 8 ... 23 Next
Advertisements