Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Questions  >  What will be output of the following c code?#... Start Learning for Free
What will be output of the following c code?
#include<stdio.h>
int main()
{
int a= sizeof(signed) +sizeof(unsigned);
int b=sizeof(const)+sizeof(volatile);
printf("%d",a+++b);
return 0;
}
  • a)
    10
  • b)
    9
  • c)
    8
  • d)
    Error
Correct answer is option 'C'. Can you explain this answer?
Verified Answer
What will be output of the following c code?#include<stdio.h>int...
Explanation: Default data type of signed, unsigned, const and volatile is intSo, a = 4 and b =4
Now, a+++b
= a++ + b
= 4 + 4 //due to post increment operator.
=8
But in Linux gcc compiler size of int is 4 byte so your out will be 16.
View all questions of this test
Most Upvoted Answer
What will be output of the following c code?#include<stdio.h>int...
Default data type of signed, unsigned, const and volatile is int. So, a = 4 and b =4

Now, a+++b

= a++ + b

= 4 + 4  /////due to post increment operator/////

=8
Free Test
Community Answer
What will be output of the following c code?#include<stdio.h>int...
Explanation:
- Variable Calculation:
- In the given code, the variable 'a' is calculated as the sum of the sizes of 'signed' and 'unsigned' data types using the sizeof operator.
- Similarly, the variable 'b' is calculated as the sum of the sizes of 'const' and 'volatile' data types using the sizeof operator.
- Size Calculation:
- The sizeof operator in C is used to determine the size of a data type in bytes.
- The size of 'signed' and 'unsigned' is typically 4 bytes each on most systems.
- The size of 'const' and 'volatile' is usually 4 bytes each on most systems as well.
- Expression Evaluation:
- Therefore, a = 4 + 4 = 8 and b = 4 + 4 = 8.
- The expression a+++b is equivalent to a++ + b which evaluates to 8 + 8 = 16.
- Output:
- The final value of the expression a+++b is 16.
- So, the output of the code will be 16.
Therefore, the correct answer is option C) 8.
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

What will be output of the following c code?#include<stdio.h>int main(){int a= sizeof(signed) +sizeof(unsigned);int b=sizeof(const)+sizeof(volatile);printf("%d",a+++b);return 0;}a)10b)9c)8d)ErrorCorrect answer is option 'C'. Can you explain this answer?
Question Description
What will be output of the following c code?#include<stdio.h>int main(){int a= sizeof(signed) +sizeof(unsigned);int b=sizeof(const)+sizeof(volatile);printf("%d",a+++b);return 0;}a)10b)9c)8d)ErrorCorrect answer is option 'C'. Can you explain this answer? for Computer Science Engineering (CSE) 2025 is part of Computer Science Engineering (CSE) preparation. The Question and answers have been prepared according to the Computer Science Engineering (CSE) exam syllabus. Information about What will be output of the following c code?#include<stdio.h>int main(){int a= sizeof(signed) +sizeof(unsigned);int b=sizeof(const)+sizeof(volatile);printf("%d",a+++b);return 0;}a)10b)9c)8d)ErrorCorrect answer is option 'C'. Can you explain this answer? covers all topics & solutions for Computer Science Engineering (CSE) 2025 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for What will be output of the following c code?#include<stdio.h>int main(){int a= sizeof(signed) +sizeof(unsigned);int b=sizeof(const)+sizeof(volatile);printf("%d",a+++b);return 0;}a)10b)9c)8d)ErrorCorrect answer is option 'C'. Can you explain this answer?.
Solutions for What will be output of the following c code?#include<stdio.h>int main(){int a= sizeof(signed) +sizeof(unsigned);int b=sizeof(const)+sizeof(volatile);printf("%d",a+++b);return 0;}a)10b)9c)8d)ErrorCorrect answer is option 'C'. Can you explain this answer? in English & in Hindi are available as part of our courses for Computer Science Engineering (CSE). Download more important topics, notes, lectures and mock test series for Computer Science Engineering (CSE) Exam by signing up for free.
Here you can find the meaning of What will be output of the following c code?#include<stdio.h>int main(){int a= sizeof(signed) +sizeof(unsigned);int b=sizeof(const)+sizeof(volatile);printf("%d",a+++b);return 0;}a)10b)9c)8d)ErrorCorrect answer is option 'C'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of What will be output of the following c code?#include<stdio.h>int main(){int a= sizeof(signed) +sizeof(unsigned);int b=sizeof(const)+sizeof(volatile);printf("%d",a+++b);return 0;}a)10b)9c)8d)ErrorCorrect answer is option 'C'. Can you explain this answer?, a detailed solution for What will be output of the following c code?#include<stdio.h>int main(){int a= sizeof(signed) +sizeof(unsigned);int b=sizeof(const)+sizeof(volatile);printf("%d",a+++b);return 0;}a)10b)9c)8d)ErrorCorrect answer is option 'C'. Can you explain this answer? has been provided alongside types of What will be output of the following c code?#include<stdio.h>int main(){int a= sizeof(signed) +sizeof(unsigned);int b=sizeof(const)+sizeof(volatile);printf("%d",a+++b);return 0;}a)10b)9c)8d)ErrorCorrect answer is option 'C'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice What will be output of the following c code?#include<stdio.h>int main(){int a= sizeof(signed) +sizeof(unsigned);int b=sizeof(const)+sizeof(volatile);printf("%d",a+++b);return 0;}a)10b)9c)8d)ErrorCorrect answer is option 'C'. Can you explain this answer? tests, examples and also practice Computer Science Engineering (CSE) tests.
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Explore Courses
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev