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 |
main(){ unsigned int i; for(i=1;i>-2;i--) printf("c aptitude"); }
Write a C program to print ‘Campus Force training’ without using even a single semicolon in the program.
#include<conio.h> main() { int x,y=2,z,a; if(x=y%2) z=2; a=2; printf("%d %d ",z,x); }
main(int argc, char **argv) { printf("enter the character"); getchar(); sum(argv[1],argv[2]); } sum(num1,num2) int num1,num2; { return num1+num2; }
void main() { int i=5; printf("%d",i++ + ++i); }
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); } }
how to return a multiple value from a function?
main() { int i=5,j=6,z; printf("%d",i+++j); }
why nlogn is the lower limit of any sort algorithm?
how can i search an element in an array
2 Answers CTS, Microsoft, ViPrak,
How to access command-line arguments?
void main() { if(~0 == (unsigned int)-1) printf(“You can answer this if you know how values are represented in memory”); }