Assigning multiple characters in an int in C language Last Updated : 30 Apr, 2018 Suggest changes Share 17 Likes Like Report Consider the following C program. C #include <stdio.h> int main(void) { int a = 'd'; printf("%d\n", a); /*OUTPUT - 100 (ASCII Code for character d)*/ int b = 'dd'; printf("%d", b); /*OUTPUT - 25700 (Explanation in detail given below)*/ return 0; } Output : 100 25700 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. C #include <stdio.h> int main(void) { int b = 'de'; printf("%d", b); return 0; } Create Quiz D Deepshikhar Bhardwaj Follow 17 Article Tags : C/C++ Puzzles Technical Scripter Computer Subject C Language Program Output +1 More Explore C BasicsC Language Introduction6 min readIdentifiers in C3 min readKeywords in C2 min readVariables in C4 min readData Types in C3 min readOperators in C8 min readDecision Making in C (if , if..else, Nested if, if-else-if )7 min readLoops in C6 min readFunctions in C5 min readArrays & StringsArrays in C4 min readStrings in C5 min readPointers and StructuresPointers in C7 min readFunction Pointer in C5 min readUnions in C3 min readEnumeration (or enum) in C5 min readStructure Member Alignment, Padding and Data Packing8 min readMemory ManagementMemory Layout of C Programs5 min readDynamic Memory Allocation in C7 min readWhat is Memory Leak? How can we avoid?2 min readFile & Error HandlingFile Handling in C11 min readRead/Write Structure From/to a File in C3 min readError Handling in C8 min readUsing goto for Exception Handling in C4 min readError Handling During File Operations in C5 min readAdvanced ConceptsVariadic Functions in C5 min readSignals in C language5 min readSocket Programming in C8 min read_Generics Keyword in C3 min readMultithreading in C9 min read My Profile ${profileImgHtml} My Profile Edit Profile My Courses Join Community Transactions Logout Like