What is the output for the program given below

typedef enum grade{GOOD,BAD,WORST,}BAD;
main()
{
BAD g1;
g1=1;
printf("%d",g1);
}




Answers were Sorted based on User's Feedback



What is the output for the program given below typedef enum grade{GOOD,BAD,WORST,}BAD; ..

Answer / chris_sreekanth

1

Is This Answer Correct ?    9 Yes 0 No

What is the output for the program given below typedef enum grade{GOOD,BAD,WORST,}BAD; ..

Answer / ashwin kumar

error is the answer as 2nd person answer

we can remove error by changing code as follows
typedef enum grade{GOOD,BAD,WORST,} bad;
main()
{
bad g1;
g1=1;
printf("%d",g1);
}

out is 1 for above code






actual error in 1st code is declearing same variable 'BAD'

at two place in enum




if my answer is wrong or any corrections are made by u plz
inform me


molugu.ashwin@gmail.com

Is This Answer Correct ?    3 Yes 0 No

What is the output for the program given below typedef enum grade{GOOD,BAD,WORST,}BAD; ..

Answer / fefrf

In linux you get following error
enum.c:2: error: `BAD' redeclared as different kind of symbol
enum.c:2: error: previous declaration of `BAD'

Is This Answer Correct ?    2 Yes 0 No




What is the output for the program given below typedef enum grade{GOOD,BAD,WORST,}BAD; ..

Answer / vijay r15

error

Is This Answer Correct ?    1 Yes 0 No

Post New Answer



More C Interview Questions

What are bit fields? What is their use?

2 Answers   Adobe,


const char * char * const What is the differnce between the above tow?.

6 Answers   Ramco, TCS,


I have a function which accepts a pointer to an int. How can I pass a constant like 5 to it?

3 Answers  


Write a C Program That Will Count The Number Of Even And Odd Integers In A Set using while loop

0 Answers   HP,


what is the function of void main()?

8 Answers  






write a fuction for accepting and replacing lowercase letter to'Z' with out using inline function.

5 Answers   Temenos,


what is unsigened char and what is the difference from char

2 Answers  


How to print "Hi World" without using semi colon?

6 Answers   Infosys,


Why does not use getgh(); and <conio.h> in c language.

3 Answers   Elofic,


how can i get the output 54321 4321 321 21 1 in c programming........???? pls help......

10 Answers   Infosys,


How does C++ help with the tradeoff of safety vs. usability?

1 Answers  


.find the output of the following program? char*myfunc(char*ptr) { ptr +=3; return (ptr); } int main() { char*x,*y; x="HELLO"; y=myfunc(x); printf("y = %s ",y); return 0; }

0 Answers  






Categories