Thursday, December 25, 2008

Enum Data Type in CProgrammming Questions with Answers

Q1.What will be output:
void main()
{
enum {a,b=32766,c,d,e=0};
clrscr();
printf("%d",a);
getch();
}
Output: error
Explanation: value of enum constant must be within range of signed int .
Maximum value of signed int is 32767 while value of d=32768

Q2.What will be output of following program?

void main()
{
enum colour { green,red=5,blue,white,yellow=10,pink };
printf(“%d %d %d %d %d %d,green,red,blue,white,yellow,pink}
};

Output: 0 5 6 7 8 10 11

No comments:

Blog List