C - Structure and Union Questions and Answers

Practice Mode
Showing 10 of 51 questions
Q31
A bit field is
  • A a pointer variable in a structure.
  • B one bit or a set of adjacent bits within a word.
  • C a pointer variable in a union.
  • D not used in C.
Answer: Option D
Q32
A bit field can be of
  • A int
  • B float
  • C double
  • D all the above
Answer: Option A
Q33
Identify the wrong statement(s).
  • A Bit fields have addresses
  • B Bit fields can be read using scanf()
  • C Bit fields can be accessed using pointer
  • D all the above
Answer: Option D
Q34
Identify the correct statement (s).
  • A Bit fields are not arrays.
  • B Bit fields cannot hold the values beyond their limits.
  • C Bit fields may be unnamed also.
  • D All the above.
Answer: Option D
Q35
About structures which of the following is true. 1. Struture members are aligned in memory depending on their data type. 2. The size of a structure may not be equal to the sum of the sizes of its members.
  • A only option 1
  • B only option 2
  • C both options 1 and 2
  • D neither option 1 nor 2
Answer: Option C
Q36
struct data { int day; int month; int year; }; main ( ) { struct date *d; ... ++d->day;          /*satementN*/ .... } then the statement statementN ...
  • A increments the pointer to point the month
  • B increment the value of day
  • C increment d by sizeof(struct date)
  • D none
Answer: Option B
Q37
struct cost_record { long cost_no; char cost_name[31]]; double current_bal; } CUST_REC; Is the sample code above a usable structure variable declaration?
  • A Yes. CUST_REC can be used to access its members with the "_>" operator.
  • B No. A typedef must be added before "struct".
  • C yes. CUST REC can be used to access its members with the "." operator.
  • D No. CUST REC must be in lowercase letters.
Answer: Option C
Q38
struct car { int speed; char type [10]; } vehicle; struct car *ptr; ptr = &vehicle; Referring to the sample code above, which of the following will make the speed equal to 200?
  • A (*ptr).speed=200;
  • B (*ptr)->speed = 200;
  • C *ptr.speed = 200;
  • D &ptr.speed = 200;
Answer: Option A
Q39
Consider the following structure. struct numname { int no; char name [25]; }; struct numname n1 [ ] = { {12, "Raja"}, {15, "selvan"}, {18, "Prema"}, {21, "Naveen"} }; The output for the following statement would be: printf ("%d, %d",n1 [ 2].no, (* (n1 + 2)). no);
  • A 18, ASCII value p
  • B 18, 18
  • C 18, ASCII value r
  • D 18, ASCII value f e
Answer: Option B
Q40
struct customer *ptr = malloc (sizeof (struct customer)); Given the sample allocation for the pointer "ptr" found above, which statement would be used to reallocate ptr to be an array of 10 elements?
  • A ptr = rea11oc ( ptr, 10 * sizeof (struct customer ));
  • B ptr = rea11oc (ptr, 9* sizeof (struct customer));
  • C rea11oc ( ptr, 9* sizeof (struct customer));
  • D rea11oc ( ptr, 10 * sizeof ( struct customer));
Answer: Option A
Questions and Answers for Competitive Exams Various Entrance Test