Select chapter



functions (3.papers)
loops (1.papers)
arrays (2.papers)
structures (3.papers)
unions (1.papers)
pointers (7.papers)
null pointers (1.papers)
strings (2.papers)
misc c concepts (1.papers)
Data structures (5.papers)
linked lists (3.papers)
trees (1.papers)
basics (5.papers)
Hide

Sponsored Links


  

c enums and typedefs interview questions and answers

Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
3
enum in c with sample code:

Is there any problem with below C program?

#include  <stdio.h>

enum status{
  false, true;  
};
  1. No problem
  2. enums should not use semicolon ";" after its member declarations, its compile time error.
  3. it will crash at run time.
  4. enums should not use semicolon ";" after its member declarations, its link time error.
Show Answer
Share Facebook gmail Twitter
4
enums in c with example:

What is the output of below C program?

#include  <stdio.h>

enum status{
  false, true  
};

int main(void)
{
    enum status capState = true;
    if(capState == 1)
        printf("capSatate is true");
    else
        printf("capState is false");
    return 0;
}
  1. capState is true
  2. capState is false
  3. invalid comparison at if capState==1, we have to compared with only either false or true, else it gives compile time error.
  4. no error, but it crashes at run time.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
9
macro example in c:
What is the output of below c program?

#include  <stdio.h>

#define print(exp) printf(#exp)

int main(void)
{
    print(hi);
    return 0;
}
  1. preprocessing error, undefined symbol hi
  2. linking time error undefined function print
  3. hi
  4. compile time error illegal arguments to printf
Show Answer
Share Facebook gmail Twitter
10
What is the output of below c program?

#include  <stdio.h>

#define print(exp) printf(#exp)

int main(void)
{
    print("hi");
    return 0;
}
  1. preprocessing error, undefined symbol "hi"
  2. linking time error undefined function print
  3. hi
  4. "hi"
Show Answer
Share Facebook gmail Twitter
Read more papers :