Structure & Union Questions and Answers

Practice Mode
Showing 10 of 95 questions
Q1
The storage is  allocated to structure only when
  • A structure members are declared
  • B structure is defined
  • C structure is called
  • D structure variable is declared
Answer: Option B
Q2
Find the output struct date { int day, month, year; }; void main ( ) { struct date today={3, 7, 6, 2007}; printf("%d% d% %d", today. day, today. month, today. year); }
  • A 3 7 6
  • B 7 6 2007
  • C Compilation error
Answer: Option C
Q3
Find the output struct faculty { int fid; int fage; char fname [20]; } 1ca; void main ( ) { static struct dilip={231, 32, "mahesh"}; printf("%d%d%ds", diip.fid); }
  • A 231 231 32 garbage
  • B 231 0 0 garbage
  • C 231 garbage garbage garbage
  • D Compilation error
Answer: Option D
Q4
Find the output struct emp { int age; char name [20]; float sal; } e={23, "bhagya", 8000.000}; void main ( ) { printf("%d%d%d", e.age, e.name, e.sal); }
  • A 23 bhagya 8000.000
  • B 23 bhagya 8000
  • C 23 bhagya suffering
  • D None of these
Answer: Option C
Q5
Can the member name of the structure be same as the name of a variable of that structure?
  • A True
  • B False
  • C True, only when structure is self referential structure
  • D False, only when structuer is self referential structure
Answer: Option A
Q6
Find the bug in the following program 1. struct emp{ 2. int eid; 3. int age; 4. char n[10]; 5. float sal; 6. double eid; 7. struct emp *p; 8. }*q;
  • A Line no. 7
  • B Line no. 8
  • C Line no. 6
  • D None of these
Answer: Option C
Q7
Find the bug in the following program? 1. struct dept { 2. int d; 3. char dname[20]; 4. float income; 5. }dn={121,"finance", 20.34}; 6. void main ( ) { 7. ++dn. income; 8. printf("%d %s %f", dn.dn, dn. dname, dn.income);}
  • A Line no. 5
  • B Line no. 7
  • C Line no.8
  • D None of these
Answer: Option D
Q8
Find the output. structr st { int x; show ( ); }: struct st s; show ( ) { printf ("%d', s.x); } void main ( ) { s.x=10; s.show(); }
  • A 10
  • B Garbage
  • C Compilation error
  • D None of these
Answer: Option C
Q9
Find the correct one from the following three compositions I. typedef struct { int month, day, year; } date; void main ( ) { int ano; date payment; } record; record employee[100]; II. typedef struct date { int month, day, year; }; void main ( ) { int ano; struct data payment; }record [100]; record employee; III. typedef struct { int month, day, year; } date; void main ( ) { int ano data payment; } employee [100];
  • A Only I and II
  • B Only III
  • C None of the above
  • D All of the above
Answer: Option B
Q10
Find the output. typedef struct bitfield { int a:7; char b:8; unsigned int c:15; }bit; void main ( ) { bit b1; printf("%d %d %d", sizeof (b1.a), sizeof (b1.b), sizeof (b1.c); }
  • A 7 8 15
  • B 2 1 2
  • C 1 1 2
  • D Compilation error
Answer: Option D
Questions and Answers for Competitive Exams Various Entrance Test