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

write a program to print data of 5 five students with structures?

0 Answers  


what is the use of ~ in c lang?????

3 Answers  


How to write a code for reverse of string without using string functions?

0 Answers   TCS,


wat is the difference between array and pointer?

4 Answers   Wipro,


write a program to print largest number of each row of a 2D array

0 Answers  






Convert the following expression to postfix and prefix X $ Y Z - M + N + P / Q / (R + S)

2 Answers  


write a C code to reverse a string using a recursive function, without swapping or using an extra memory.

9 Answers   Motorola, TCS, Wipro,


how does a general function , that accepts an array as a parameter, "knows" the size of the array ? How should it define it parameters list ?

2 Answers   Patni, TCS,


Write a program which has the following seven functions. The functions should be: • main() this calls the other 6 functions • fget_long() a function which returns a long data type from a file • fget_short() a function which returns a short integer variable from a file • fget_float() a function which returns a floating point variable from a file • fprt_long() a function which prints its single, long argument into a file • fprt_short() a function which prints its single, short argument into a file • fprt_float() a function which prints its single, floating point argument into a file. You should use fscanf() to get the values of the variables from the input (the file) and fprintf() to print the values to the other file. Pay attention to using the correct format for each of the data types.

0 Answers  


program to print upper & lower triangle of a matrix

2 Answers   TCS,


Q. where is the below variables stored ? - volatile, static, register

3 Answers   Bosch,


what is difference between c and c++

4 Answers  






Categories