
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 7197 Articles for C++

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: The extern is used when the compiler needs to be informed about the existence of a variable that is declared in another file. ... Read More

23K+ Views
In C++, the reference variable is an alternate name of already existing variable. It cannot be changed to refer another variable and should be initialized at the time of declaration and cannot be NULL. The operator '&' is used to declare reference variable. Reference variables are commonly used for parameter passing in functions, returning values, and aliasing existing variables. Syntax Following is the syntax for the reference variable in c++: datatype &refer_var = variable_name; Here, datatype − The datatype of variable like int, char, float etc. variable_name − This is ... Read More

2K+ Views
intThe datatype int is used to store the integer values. It could be signed or unsigned. The datatype int is of 32-bit or 4 bytes. It requires less memory area than long to store a value. The keyword “int” is used to declare an integer variable.The following is the syntax of int datatype.int variable_name;Here,variable_name − The name of variable given by user.The following is an example of int datatype.Example Live Demo#include using namespace std; int main() { int a = 8; int b = 10; int c = a+b; cout

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 unsigned type. Following is the description of "%zu" format: z is a length modifier. u stands for an unsigned type. C Example to Print Value of size_t Variable In this example, we demonstrate a C program that correctly prints a ... Read More

3K+ Views
g++GNU C++ Compiler ( g++ ) is a compiler in Linux which is used to compile C++ programs. It compiles both files with extension .c and .cpp as C++ files.The following is the compiler command to compile C++ program.g++ program.cpp -o filenameHere,filename − The name of file with .c or .cpp extension.The following is an example of using g++ compiler.Example Live Demo#include using namespace std; int main() { int a = 20; cout

10K+ Views
Static variables are variables that remain in memory while the program is running i.e. their lifetime is the entire program run. This is different than automatic variables as they remain in memory only when their function is running and are destroyed when the function is over.The static variables are stored in the data segment of the memory. The data segment is a part of the virtual address space of a program.All the static variables that do not have an explicit initialization or are initialized to zero are stored in the uninitialized data segment( also known as the BSS segment). Compared ... Read More

12K+ Views
Both pre-increment and post-increment are used to represent the expression of increasing a value by adding 1. Their behavior are different because pre-increment (++i) increases the value before it is used in an expression, while post-increment (i++) increases it after. Below is the key-terms of pre-increment and post-increment in C/C++: Pre-increment (++i) : Before assigning the value to the variable, the value is incremented by one. Post-increment (i++) : After assigning the value to the variable, the value is incremented. Syntax of Using Pre and Post Increment Operators The following is the basic syntax of pre-increment and post-increment ... Read More

335 Views
Given are the two integer variables, a and b. To calculate the sum without using any arithmetic operators such as + or -. We can achieve this by using bitwise operations, which allow us to calculate the sum. Here, we have some approaches in C and C++ to solve this problem as follows: Sum of Two Integers Using Bitwise XOR Sum of Two Integers Using Vector Sum of Two Integers Using malloc() and free() Sum of Two Integers Using Bitwise XOR (^) To perform the sum ... Read More

779 Views
In C++, converting a single character into an integer is possible using various techniques like STL functions say atoi() and stoi(). Also, you can solve this with the help of ASCII value or stringstream function. Converting Single Char into Int Here, we have list down of four approaches that help to convert the single character into an integer form as follows: Using ASCII Subtraction Using stoi() Function Using atoi() Function Using stringstream Function Using ASCII Subtraction ASCII subtraction converts a digit character to an integer by subtracting '0' from it. This works because digit characters are stored sequentially ... Read More

899 Views
In C language, the void pointers are converted implicitly to the object pointer type. The function malloc() returns void * in C89 standard. In earlier versions of C, malloc() returns char *. In C++ language, by default malloc() returns int value. So, the pointers are converted to object pointers using explicit casting.The following is the syntax of allocating memory in C language.pointer_name = malloc(size);Here, pointer_name − Any name given to the pointer.size − Size of allocated memory in bytes.The following is an example of malloc() in C language.Example Live Demo#include #include int main() { int n = 4, ... Read More