
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++

7K+ Views
Here we will see what are the basic differences of do-while loop and the while loop in C or C++.A while loop in C programming repeatedly executes a target statement as long as a given condition is true. The syntax is like below.while(condition) { statement(s); }Here, statement(s) may be a single statement or a block of statements. The condition may be any expression, and true is any nonzero value. The loop iterates while the condition is true.When the condition becomes false, the program control passes to the line immediately following the loop.Example#include int main () { int ... Read More

3K+ Views
In C and C++, every function is stored in the computer's memory, and each function has a memory address just like all other variables. In this article, our task is to see how we can access the address of a function and display it in both C and C++. Accessing Address of a Function To access the address of a function, we simply use its name without parentheses. When we print a function name with parentheses like hello(), we're calling the function. But if we print just hello, it gives us the memory address where the function is stored. ... Read More

4K+ Views
Here we will see what is the pre-increment and post-increment in C or C++. The pre-increment and post-increment both are increment operators. But they have little differences.The pre-increment operator increments the value of a variable at first, then sends the assign it to some other variable, but in the case of postincrement, it at first assign to a variable, then increase the value.Example#include using namespace std; main() { int x, y, z; x = 10; y = 10; z = ++x; //z will hold 11 cout

493 Views
Here we will see how to generate the preprocessed or preprocessor code from the source code of a C or C++ program.To see the preprocessed code using g++ compiler, we have to use the ‘-E’ option with the g++.Preprocessor includes all of the # directives in the code, and also expands the MACRO function.Syntaxg++ -E program.cppExample#define PI 3.1415 int main() { float a = PI, r = 5; float c = a * r * r; return 0; }Output$ g++ -E test_prog.cpp int main() { float a = 3.1415, r = 5; float c = a * r * r; return 0; }

309 Views
One of the most frequent question is what will be the value of some uninitialized primitive data values in C or C++? Well the answer will be different in different systems. We can assume the compiler will assign 0 into the variables. It can be done for integer as 0, for float 0.0, but what will be for character type data?Example#include using namespace std; main() { char a; float b; int c; double d; long e; cout

7K+ Views
Here we will see how to generate assembly language output from C or C++ source code using gcc.The gcc provides a great feature to get all intermediate outputs from a source code while executing. To get the assembler output we can use the option ‘-S’ for the gcc. This option shows the output after compiling, but before sending to the assembler. The syntax of this command is like below.gcc –S program.cppNow, let us see how to output will be look like. Here we are using a simple program. In this program two numbers are stored into the variables x and ... Read More

4K+ Views
A structures (or struct) is a user-defined data type, which is used to group and store variables of different data types inside a single name. But in C, structures can store only data members whereas C++ can store member functions, constructors, destructors, and even inheritance which is similar to classes in C++, but the only difference between struct and classes is that struct members are public by default. In this following article we will see how structure differs in both C and C++ in detail. Structures in C The structures in C is a user-defined data type, which is used ... Read More

2K+ Views
A structure in C++ is a user-defined data type, which is used to group and store variables of different data types under a single name. In this article we will see how to sort an array of structures using conditions on member variables. For this we will be using the sort() function which is defined under header file. Syntax Here is the following syntax of sort() function. sort(start_index, end_index, comparison_function); start_index is an iterator (or pointer) to the first element of the array of structures.end_index is an iterator (or pointer) to one past the last element (means last_index + ... Read More

3K+ Views
The C Preprocessor is not a part of the compiler, but is a separate step in the compilation process. In simple terms, a C Preprocessor is just a text substitution tool and it instructs the compiler to do required pre-processing before the actual compilation. We'll refer to the C Preprocessor as CPP.All preprocessor commands begin with a hash symbol (#). It must be the first nonblank character, and for readability, a preprocessor directive should begin in the first column. The following section lists down all the important preprocessor directives −Sr.NoDirectives & Descriptions1#defineSubstitutes a preprocessor macro.2#includeInserts a particular header from another ... Read More

712 Views
The #define, const, and Enum are all used for declaring constant values, but their behaviours and use cases differ. The #define is a preprocessor directive, which is used to define a macro (it is a string or name, in which you can assign a constant value), whereas const is a keyword with which you can declare a variable with a constant value. Whereas, an Enum is a special user-defined data type that represents a group of constants. In the following article, we will learn about all three in detail. Enumeration (Enum) An Enumeration (or Enum) is a user-defined data type ... Read More