typedef struct error{int warning, error, exception;}error;
main()
{
error g1;
g1.error =1;
printf("%d",g1.error);
}
Answer / susie
Answer :
1
Explanation
The three usages of name errors can be distinguishable
by the compiler at any instance, so valid (they are in
different namespaces).
Typedef struct error{int warning, error, exception;}error;
This error can be used only by preceding the error by struct
kayword as in:
struct error someError;
typedef struct error{int warning, error, exception;}error;
This can be used only after . (dot) or -> (arrow) operator
preceded by the variable name as in :
g1.error =1;
printf("%d",g1.error);
typedef struct error{int warning, error, exception;}error;
This can be used to define variables without using the
preceding struct keyword as in:
error g1;
Since the compiler can perfectly distinguish between these
three usages, it is perfectly legal and valid.
Note
This code is given here to just explain the concept
behind. In real programming don’t use such overloading of
names. It reduces the readability of the code. Possible
doesn’t mean that we should use it!
Is This Answer Correct ? | 2 Yes | 0 No |
Write a C program to print ‘Campus Force training’ without using even a single semicolon in the program.
write a simple calculator c program to perform addition, subtraction, mul and div.
0 Answers United Healthcare, Virtusa,
#ifdef something int some=0; #endif main() { int thing = 0; printf("%d %d\n", some ,thing); }
void main() { static int i=i++, j=j++, k=k++; printf(“i = %d j = %d k = %d”, i, j, k); }
writte a c-programm to display smill paces
write a program for area of circumference of shapes
Give a one-line C expression to test whether a number is a power of 2.
How will you print % character? a. printf(“\%”) b. printf(“\\%”) c. printf(“%%”) d. printf(“\%%”)
main() { float i=1.5; switch(i) { case 1: printf("1"); case 2: printf("2"); default : printf("0"); } }
main() { char *p = “ayqm”; char c; c = ++*p++; printf(“%c”,c); }
4. Main() { Int i=3,j=2,c=0,m; m=i&&j||c&I; printf(“%d%d%d%d”,I,j,c,m); }
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*/ }