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 is diff between localstatic and globalstatis variable possible 2 use in another file...?

2 Answers   HCL,


Differentiate Source Codes from Object Codes

1 Answers  


main() { float a=3.2e40; printf("%d",a); }

9 Answers   Satyam,


3. Program to print all possible substrings. ex: String S St Str Stri Strin String t tr tri trin tring r

3 Answers   Huawei,


how can use subset in c program and give more example

0 Answers  






#include<stdio.h> main() { int a[3]; int *I; a[0]=100;a[1]=200;a[2]=300; I=a; Printf(“%d\n”, ++*I); Printf(“%d\n”, *++I); Printf(“%d\n”, (*I)--); Printf(“%d\n”, *I); } what is the o/p a. 101,200,200,199 b. 200,201,201,100 c. 101,200,199,199 d. 200,300,200,100

1 Answers  


4) Write a program that takes a 5 digit number and calculates 2 power that number and prints it. i have done maximum par but i m findind problem in the commented area. please help...

3 Answers  


What kind of structure is a house?

0 Answers  


What is #line in c?

0 Answers  


can u write a program in C, which does not use = (eqaul)or any arithmatic assignment(like -=,+=,*= etc) operator to swap to number?

2 Answers  


write program on arrays

3 Answers   GE, Polycab,


What is difference between constant pointer and constant variable?

0 Answers   Hexaware,


Categories