What is the output for the program given below

typedef enum errorType{warning, error,
exception,}error;

main()

{

error g1;

g1=1;

printf("%d",g1);

}



What is the output for the program given below typedef enum errorType{warning, error,..

Answer / susie

Answer :

Compiler error: Multiple declaration for error

Explanation

The name error is used in the two meanings. One means
that it is a enumerator constant with value 1. The another
use is that it is a type name (due to typedef) for enum
errorType. Given a situation the compiler cannot distinguish
the meaning of error to know in what sense the error is used:

error g1;

g1=error;

// which error it refers in each case?

When the compiler can distinguish between usages then
it will not issue error (in pure technical terms, names can
only be overloaded in different namespaces).

Note: the extra comma in the declaration,

enum errorType{warning, error, exception,}

is not an error. An extra comma is valid and is provided
just for programmer’s convenience.

Is This Answer Correct ?    6 Yes 0 No

Post New Answer

More C Code Interview Questions

Extend the sutherland-hodgman clipping algorithm to clip three-dimensional planes against a regular paralleiepiped

1 Answers   IBM,


write a simple calculator c program to perform addition, subtraction, mul and div.

0 Answers   United Healthcare, Virtusa,


Program to Delete an element from a doubly linked list.

4 Answers   College School Exams Tests, Infosys,


What is your nationality?

1 Answers   GoDB Tech,


main() { int a[10]; printf("%d",*a+1-*a+3); }

1 Answers  






#include<stdio.h> int main() { int x=2,y; y=++x*x++*++x; printf("%d",y); } Output for this program is 64. can you explain how this output is come??

1 Answers  


What is the main difference between STRUCTURE and UNION?

13 Answers   HCL,


main() { int i=400,j=300; printf("%d..%d"); }

3 Answers  


Cau u say the output....?

1 Answers  


how to concatenate the two strings

1 Answers  


main() { printf("\nab"); printf("\bsi"); printf("\rha"); }

3 Answers  


what is the code of the output of print the 10 fibonacci number series

2 Answers  


Categories