Programming in C - Structure and Union

11. Consider the following declaration.
struct addr
{
char city [10];
char street [20];
int pincode;
};
struct
{
char name[20];
int sex;
struct addr locate;
} criminal, *kd * &criminal;
The third character in the criminal name can be accessed by

Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


12. Consider the following declaration.
struct addr
{
char city [10];
char street [20];
int pincode;
};
struct
{
char name[20];
int sex;
struct addr locate;
} criminal, *kd * &criminal;
*(kd —> name + 2) can be used instead of

Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


13. Assuming that bit-fields are accommodated from right to left and word size is 16-bits
Consider the declaration
static struct
  {
 unsigned a : 5;
 unsigned b : 5;
  unsigned c : 5;
  unsigned d : 5;
  } v = (1, 2, 3, 4);
information about d will be in the

Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


14. Assuming that bit-fields are accommodated from right to left and word size is 16-bits
Consider the declaration
static struct {
  unsigned a : 5;
  unsigned b : 5;
  unsigned c : 5;
  unsigned d : 5; } v = (1, 2, 3, 4);
If the declaration unsigned c : 5; is replaced by unsigned : 6;
then,

  • Option : D
  • Explanation :
    A bit-fiels need not be named
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


15. Assuming that bit-fields are accommodated from right to left and word size is 16-bits
Consider the declaration
static struct {
&emsp: unsigned a : 5;
&emsp: unsigned b : 5;
&emsp: unsigned c : 5;
&emsp: unsigned d : 5;
&emsp: } v = (1, 2, 3, 4);
Consider the declaration
struct wer {
&emsp: unsigned a : 5;
&emsp: unsigned : 0;
&emsp: unsigned b : 3;
&emsp: unsigned : 0;
&emsp: unsigned c : 2 ;
&emsp: unsigned : 0 ;
&emsp: } v;
The storage needed for v is

Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *