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

main() { int i; clrscr(); for(i=0;i<5;i++) { printf("%d\n", 1L << i); } } a. 5, 4, 3, 2, 1 b. 0, 1, 2, 3, 4 c. 0, 1, 2, 4, 8 d. 1, 2, 4, 8, 16

4 Answers   HCL,


create a login program that ask username and password. if you input username or password 3 times wrong, the program will terminate else the program will prompt a message "congratulations"

2 Answers  


What are the following notations of defining functions known as? i. int abc(int a,float b) { /* some code */ } ii. int abc(a,b) int a; float b; { /* some code*/ }

1 Answers  


program to find magic aquare using array

4 Answers   HCL,


main(int argc, char **argv) { printf("enter the character"); getchar(); sum(argv[1],argv[2]); } sum(num1,num2) int num1,num2; { return num1+num2; }

1 Answers  






main() { int i = 257; int *iPtr = &i; printf("%d %d", *((char*)iPtr), *((char*)iPtr+1) ); }

1 Answers   CSC,


Find your day from your DOB?

15 Answers   Accenture, Microsoft,


struct Foo { char *pName; }; main() { struct Foo *obj = malloc(sizeof(struct Foo)); clrscr(); strcpy(obj->pName,"Your Name"); printf("%s", obj->pName); } a. Your Name b. compile error c. Name d. Runtime error

3 Answers   HCL,


I need your help, i need a Turbo C code for this problem.. hope u'll help me guys.? Your program will have a 3x3 array. The user will input the sum of each row and each column. Then the user will input 3 values and store them anywhere, or any location or index, temporarily in the array. Your program will supply the remaining six (6) values and determine the exact location of each value in the array. Example: Input: Sum of row 1: 6 Sum of row 2: 15 Sum of row 3: 24 Sum of column 1: 12 Sum of column 2: 15 Sum of column 3: 18 Value 1: 3 Value 2: 5 Value 3: 6 Output: Sum of Row 1 2 3 6 4 5 6 15 7 8 9 24 Sum of Column 12 15 18 Note: Your program will not necessary sort the walues in the array Thanks..

0 Answers  


Is the following code legal? typedef struct a { int x; aType *b; }aType

1 Answers  


main() { int c[ ]={2.8,3.4,4,6.7,5}; int j,*p=c,*q=c; for(j=0;j<5;j++) { printf(" %d ",*c); ++q; } for(j=0;j<5;j++){ printf(" %d ",*p); ++p; } }

1 Answers  


Printf can be implemented by using __________ list.

3 Answers  


Categories