C good questions and answer

Good questions in c programming language.

(1) What will be output of the following program?

void  main(){
enum data{a,b,c};
clrscr();
printf("%i %i %i",a,b,c);
getch();
}

Output: 0 1 2
Explanation:
By default initial value of first enum constant is zero. Value of next enum constant will be:
Next_enum_constant_value=previous_enum_constant_value+1

(2) What will be output of the following program?

void main(){
enum data{a,b=5,c};
clrscr();
printf("%i %i %i",a,b,c);
getch();
}

Output: 0 5 6
Explanation:
By default initial value of first enum constant is zero. Value of next enum constant will be:
Next_enum_constant_value=previous_enum_constant_value+1
This formal is valid if enum constant is not explicitly initialized. Otherwise it will store initialized value.

(3) What will be output of the following program ?

void main(){
enum data1{a,c,e}p;
enum data2{b,d,f}q;
p=q;
clrscr();
printf("%i",p);
getch();

}

Output: 0
Standard predefined stream question in c programming language.

(4) What will be output of the following program?

#include"stdio.h"
void  main(){

clrscr();
fputs("ERROR page",stderr);
getch();

}

Output: ERROR PAGE
Explanation:
It will display the output of program on standard error page
Post a Comment