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? ( according to GCC compiler)
#include<stdio.h> int main()
{ signed x;
unsigned y;
x = 10 +- 10u + 10u +- 10;
y = x
; if(x==y)
printf("%d %d",x,y);
else if(x!=y)
printf("%u %u",x,y);
return 0;
}
  • a)
    0 0
  • b)
    65536 -10
  • c)
    0 65536
  • d)
    Compilation error
Correct answer is option 'A'. Can you explain this answer?
Verified Answer
What will be output of the following c code? ( according to GCC compil...
 Consider on the expression:
x = 10 +- 10u + 10u +- 10;
10: It is signed integer constant.
10u: It is unsigned integer constant.
X: It is signed integer variable.
As we know operators enjoy higher precedence than binary operators. So
x = 10 + (-10u) + 10u + (-10);
= 10 + -10 + 10 + (-10);
= 0
So, Corresponding signed value of unsigned 10u is +10.
View all questions of this test
Most Upvoted Answer
What will be output of the following c code? ( according to GCC compil...
Explanation:

Variables:
- x: signed integer variable
- y: unsigned integer variable

Code Execution:
1. x = 10 + (-10u) + 10u + (-10)
2. Simplifying the expression:
x = 10 + (-10) + 10 = 10 - 10 + 10 = 10
3. y = x = 10

Comparison:
- As x and y have the same value (10), the if condition (x == y) is true.
- Hence, the output will be '0 0'.
Therefore, option 'A' is the correct answer.
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

What will be output of the following c code? ( according to GCC compiler)#include<stdio.h> int main(){ signed x;unsigned y;x = 10 +- 10u + 10u +- 10;y = x; if(x==y)printf("%d %d",x,y);else if(x!=y)printf("%u %u",x,y);return 0;}a)0 0b)65536 -10c)0 65536d)Compilation errorCorrect answer is option 'A'. Can you explain this answer?
Question Description
What will be output of the following c code? ( according to GCC compiler)#include<stdio.h> int main(){ signed x;unsigned y;x = 10 +- 10u + 10u +- 10;y = x; if(x==y)printf("%d %d",x,y);else if(x!=y)printf("%u %u",x,y);return 0;}a)0 0b)65536 -10c)0 65536d)Compilation errorCorrect answer is option 'A'. 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? ( according to GCC compiler)#include<stdio.h> int main(){ signed x;unsigned y;x = 10 +- 10u + 10u +- 10;y = x; if(x==y)printf("%d %d",x,y);else if(x!=y)printf("%u %u",x,y);return 0;}a)0 0b)65536 -10c)0 65536d)Compilation errorCorrect answer is option 'A'. 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? ( according to GCC compiler)#include<stdio.h> int main(){ signed x;unsigned y;x = 10 +- 10u + 10u +- 10;y = x; if(x==y)printf("%d %d",x,y);else if(x!=y)printf("%u %u",x,y);return 0;}a)0 0b)65536 -10c)0 65536d)Compilation errorCorrect answer is option 'A'. Can you explain this answer?.
Solutions for What will be output of the following c code? ( according to GCC compiler)#include<stdio.h> int main(){ signed x;unsigned y;x = 10 +- 10u + 10u +- 10;y = x; if(x==y)printf("%d %d",x,y);else if(x!=y)printf("%u %u",x,y);return 0;}a)0 0b)65536 -10c)0 65536d)Compilation errorCorrect answer is option 'A'. 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? ( according to GCC compiler)#include<stdio.h> int main(){ signed x;unsigned y;x = 10 +- 10u + 10u +- 10;y = x; if(x==y)printf("%d %d",x,y);else if(x!=y)printf("%u %u",x,y);return 0;}a)0 0b)65536 -10c)0 65536d)Compilation errorCorrect answer is option 'A'. 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? ( according to GCC compiler)#include<stdio.h> int main(){ signed x;unsigned y;x = 10 +- 10u + 10u +- 10;y = x; if(x==y)printf("%d %d",x,y);else if(x!=y)printf("%u %u",x,y);return 0;}a)0 0b)65536 -10c)0 65536d)Compilation errorCorrect answer is option 'A'. Can you explain this answer?, a detailed solution for What will be output of the following c code? ( according to GCC compiler)#include<stdio.h> int main(){ signed x;unsigned y;x = 10 +- 10u + 10u +- 10;y = x; if(x==y)printf("%d %d",x,y);else if(x!=y)printf("%u %u",x,y);return 0;}a)0 0b)65536 -10c)0 65536d)Compilation errorCorrect answer is option 'A'. Can you explain this answer? has been provided alongside types of What will be output of the following c code? ( according to GCC compiler)#include<stdio.h> int main(){ signed x;unsigned y;x = 10 +- 10u + 10u +- 10;y = x; if(x==y)printf("%d %d",x,y);else if(x!=y)printf("%u %u",x,y);return 0;}a)0 0b)65536 -10c)0 65536d)Compilation errorCorrect answer is option 'A'. 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? ( according to GCC compiler)#include<stdio.h> int main(){ signed x;unsigned y;x = 10 +- 10u + 10u +- 10;y = x; if(x==y)printf("%d %d",x,y);else if(x!=y)printf("%u %u",x,y);return 0;}a)0 0b)65536 -10c)0 65536d)Compilation errorCorrect answer is option 'A'. 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