Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


typedef struct error{int warning, error, exception;}error;

main()

{

error g1;

g1.error =1;

printf("%d",g1.error);

}



typedef struct error{int warning, error, exception;}error; main() { ..

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

Post New Answer

More C Code Interview Questions

Write a C function to search a number in the given list of numbers. donot use printf and scanf

4 Answers   Honeywell, TCS,


String copy logic in one line.

11 Answers   Microsoft, NetApp,


main() { int a=10,*j; void *k; j=k=&a; j++; k++; printf("\n %u %u ",j,k); }

1 Answers  


main() { char s[ ]="man"; int i; for(i=0;s[ i ];i++) printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]); }

1 Answers   DCE,


What are segment and offset addresses?

2 Answers   Infosys,






Can you send Code for Run Length Encoding Of BMP Image in C Language in linux(i.e Compression and Decompression) ?

0 Answers   Honeywell,


main() { int i; i = abc(); printf("%d",i); } abc() { _AX = 1000; }

2 Answers  


1. const char *a; 2. char* const a; 3. char const *a; -Differentiate the above declarations.

3 Answers  


Write a program using one dimensional array to assign values and then display it on the screen. Use the formula a[i]=i*10 to assign value to an element.

1 Answers   Samar State University,


main() { char *p = “ayqm”; char c; c = ++*p++; printf(“%c”,c); }

1 Answers  


Who could write how to find a prime number in dynamic array?

0 Answers  


1) int i=5; j=i++ + i++ + i++; printf("%d",j);This code gives the answer 15.But if we replace the value of the j then anser is different?why? 2)int i=5; printf("%d",i++ + i++ + i++); this givs 18.

8 Answers   IBPS, Infosys, TCS,






Categories