What is the output for the program given below
typedef enum errorType{warning, error,
exception,}error;
main()
{
error g1;
g1=1;
printf("%d",g1);
}
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 |
write a c program to Create employee record by taking details like name, employee id, address and phone number. While taking the phone number, take either landline or mobile number. Ensure that the phone numbers of the employee are unique. Also display all the details
main() { unsigned char i=0; for(;i>=0;i++) ; printf("%d\n",i); }
#define SQR(x) x * x main() { printf("%d", 225/SQR(15)); } a. 1 b. 225 c. 15 d. none of the above
void main() { int *mptr, *cptr; mptr = (int*)malloc(sizeof(int)); printf(“%d”,*mptr); int *cptr = (int*)calloc(sizeof(int),1); printf(“%d”,*cptr); }
#include<conio.h> main() { int x,y=2,z,a; if(x=y%2) z=2; a=2; printf("%d %d ",z,x); }
why the range of an unsigned integer is double almost than the signed integer.
how can i search an element in an array
2 Answers CTS, Microsoft, ViPrak,
main() { struct student { char name[30]; struct date dob; }stud; struct date { int day,month,year; }; scanf("%s%d%d%d", stud.rollno, &student.dob.day, &student.dob.month, &student.dob.year); }
How can you relate the function with the structure? Explain with an appropriate example.
There were 10 records stored in “somefile.dat” but the following program printed 11 names. What went wrong? void main() { struct student { char name[30], rollno[6]; }stud; FILE *fp = fopen(“somefile.dat”,”r”); while(!feof(fp)) { fread(&stud, sizeof(stud), 1 , fp); puts(stud.name); } }
main() { int i=5; printf("%d",++i++); }
main() { int i = 3; for (;i++=0;) printf(“%d”,i); }