C - Structure and Union

C - Structure and Union
31. A bit field is
  • a pointer variable in a structure.
  • one bit or a set of adjacent bits within a word.
  • a pointer variable in a union.
  • not used in C.
Show Answer
32. A bit field can be of
  • int
  • float
  • double
  • all the above
Show Answer
33. Identify the wrong statement(s).
  • Bit fields have addresses
  • Bit fields can be read using scanf()
  • Bit fields can be accessed using pointer
  • all the above
Show Answer
34. Identify the correct statement (s).
  • Bit fields are not arrays.
  • Bit fields cannot hold the values beyond their limits.
  • Bit fields may be unnamed also.
  • All the above.
Show Answer
35. 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.
  • only option 1
  • only option 2
  • both options 1 and 2
  • neither option 1 nor 2
Show Answer
36. struct data
{
int day;
int month;
int year;
};
main ( )
{
struct date *d;
...
++d->day;          /*satementN*/
....
}
then the statement statementN
...
  • increments the pointer to point the month
  • increment the value of day
  • increment d by sizeof(struct date)
  • none
Show Answer
37. 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?
  • Yes. CUST_REC can be used to access its members with the "_>" operator.
  • No. A typedef must be added before "struct".
  • yes. CUST REC can be used to access its members with the "." operator.
  • No. CUST REC must be in lowercase letters.
Show Answer
38. 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?
  • (*ptr).speed=200;
  • (*ptr)->speed = 200;
  • *ptr.speed = 200;
  • &ptr.speed = 200;
Show Answer
39. 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);

  • 18, ASCII value p
  • 18, 18
  • 18, ASCII value r
  • 18, ASCII value f e
Show Answer
40. 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?
  • ptr = rea11oc ( ptr, 10 * sizeof (struct customer ));
  • ptr = rea11oc (ptr, 9* sizeof (struct customer));
  • rea11oc ( ptr, 9* sizeof (struct customer));
  • rea11oc ( ptr, 10 * sizeof ( struct customer));
Show Answer
Questions and Answers for Competitive Exams Various Entrance Test