C Programming - Structures, Unions, Enums
Exercise : Structures, Unions, Enums - Find Output of Program
11.
What will be the output of the program ?
#include<stdio.h>
int main()
{
enum days {MON=-1, TUE, WED=6, THU, FRI, SAT};
printf("%d, %d, %d, %d, %d, %d\n", ++MON, TUE, WED, THU, FRI, SAT);
return 0;
}
Answer: Option
Explanation:
Because ++ or -- cannot be done on enum value.
12.
What will be the output of the program ?
#include<stdio.h>
struct course
{
int courseno;
char coursename[25];
};
int main()
{
struct course c[] = { {102, "Java"},
{103, "PHP"},
{104, "DotNet"} };
printf("%d ", c[1].courseno);
printf("%s\n", (*(c+2)).coursename);
return 0;
}
13.
What will be the output of the program given below in 16-bit platform ?
#include<stdio.h>
int main()
{
enum value{VAL1=0, VAL2, VAL3, VAL4, VAL5} var;
printf("%d\n", sizeof(var));
return 0;
}
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers