
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 1339 Articles for C

362 Views
The character type data is stored by its ASCII value internally in C or C++. If we want to print a single character as integer, we will get the ASCII value. But when we are trying to print more than one character using a single quote, then it will print some strange output.Please check the following program to get the idea.Example#include int main() { printf("%d", 'A'); printf("%d", 'AA'); printf("%d", 'ABC'); }Output65 16705 4276803The ASCII of A is 65. So at first it is showing 65 (01000001). Now for AA, it is showing 16705. This is ASCII ... 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

288 Views
We know that we need to declare variables before using it in our code. However, we variables can be assigned with 0 or 1 without declaration. In the following example we can see this.Example#include #include x, y, array[3]; // implicit initialization of some variables int main(i) { //The argument i will hold 1 int index; printf("x = %d, y = %d", x, y); for(index = 0; index < 3; index++) printf("Array[%d] = %d", i, array[i]); printf("The value of i : %d", i); }Outputx = 0, y = 0 ... Read More

1K+ Views
We have used the integer and character variables many times in our program. Here we will see how they are stored in the memory.In C the character values are also stored as integers. In the following code, we shall put 270 into a character type data. So the binary equivalent of 270 is 100001110, but takes only first 8-bits from right. So the result will be (00001110), that is 14. Then stores the value into variable a. It also gives warning for overflow.In the next variable y, we are trying to store negative number say -130. The negative number will ... 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

492 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; }

6K+ Views
Here we will see how the C programs are executed in a system. This is basically the compilation process of a C program.The following diagram will show how a C Source Code can be executed.In the above diagram there are different steps −C Code − This is the code that you have written. This code is sent to the Preprocessors section.Preprocessing − In this section the preprocessor files are attached with our code. We have use different header files like stdio.h, math.h etc. These files are attached with the C Source code and the final C Source generates. (‘#include’, ‘#define’ ... Read More

308 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

6K+ Views
In C or C++, we can use the constant variables. The constant variable values cannot be changed after its initialization. In this section we will see how to change the value of some constant variables.If we want to change the value of constant variable, it will generate compile time error. Please check the following code to get the better idea.Example#include main() { const int x = 10; //define constant int printf("x = %d", x); x = 15; //trying to update constant value printf("x = %d", x); }Output[Error] assignment of read-only variable 'x'So this is generating ... Read More

2K+ Views
In this section we will see what are the differences between macros and functions in C. The macros are pre-processed, so it means that all the macros will be preprocessed while it is compiled. The functions are not preprocessed, but compiled.In macros no type checking is done, so it may occur some problems for different types of inputs. In the case of functions, this is not done. Also for macros if the inputs are not properly maintained, then it may generate some invalid results. Please check the following program to get the idea about the problem.Example#include #define SQUARE(x) x ... Read More