Discussion
What will be the output of the following C code?
#include <stdio.h>
enum sanfoundry
{
a=1,b
};
enum sanfoundry1
{
c,d
};
int main()
{
enum sanfoundry1 s1=c;
enum sanfoundry1 s=a;
enum sanfoundry s2=d;
printf("%d",s);
printf("%d",s1);
printf("%d",s2);
}
Answer: D
Correct answer: 101
Take each in turn. s1 = c, and in sanfoundry1 c is 0. s = a, and a is 1. s2 = d, which is 1. The prints are in the order s, s1, s2, giving 101. Note that C does not object to assigning a value of one enumeration to a variable of another - they are all just ints.
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development