Consider the following C program.
We can easily guess that the output for ‘d’ is 100 as 100 is ASCII value of character ‘d’.
Let us consider below line
int a = 'dd'
(%d, a) prints 25700 as output
01100100 01100100 (Binary of 100 100)
Assuming int is of 2 bytes, starting byte is occupied by first character ‘d’ and second byte by second character ‘d’. Therefore overall binary involves 0110010001100100 i.e 2^14 + 2^13 + 2^10 + 2^6 + 2^5 + 2^2 = 25700.
Now guess the output of following code.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Difference between const int*, const int * const, and int const *
- Assigning multiple variables in one line in Python
- Assigning an integer to float and comparison in C/C++
- Explicitly assigning port number to client in Socket
- Difference between "int main()" and "int main(void)" in C/C++?
- Difference between sizeof(int *) and sizeof(int) in C/C++
- Difference Between C Language and LISP Language
- Replace minimal number of characters to make all characters pair wise distinct
- Implicit return type int in C
- Print a long int in C using putchar() only
- What’s difference between “array” and “&array” for “int array” ?
- int (1 sign bit + 31 data bits) keyword in C
- C/C++ program to find the size of int, float, double and char
- What is the meaning of invalid literal for int() with base = ' '?
- Java Program to Convert long to int
- Java Program to Convert int to long
- C Programming Language Standard
- A C Programming Language Puzzle
- C Language Introduction
- Arrays in C Language | Set 2 (Properties)
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.