Top

Structures, Unions, Enums

81.

What will be output for the following code?

Answer:

Enter details here

82.

Consider the following C declaration

struct (
short s[5];
union {
float y;
long z;
}u;
}t;

Assume that the objects of the type short, float and long occupy 2 bytes, 4 bytes and 8 bytes, respectively. The memory requirement for variable t, ignoring alignment consideration, is

Answer: B

No answer description available for this question.

Enter details here

83.

Which of the following cannot be a structure member?

Answer: A

No answer description available for this question

Enter details here

Answer: D

No answer description available for this question

Enter details here

85.

The correct syntax to access the member of the ith structure in the array of structures is?

Assuming: 
struct temp
{
  int b;
}s[50];

 

Answer: D

 

The correct syntax to access the member of the ith structure in the array of structures is s[i].b;

Enter details here

87.

What is the output of this program?

#include 
int main()
{
    enum days {MON=-1, TUE, WED=4, THU, FRI, SAT};
    printf("%d, %d, %d, %d, %d, %d", MON, TUE, WED, THU, FRI, SAT);
    return 0;
}

 

Answer: A

No answer description available for this question

Enter details here

88.

Predict the output of following C program

#include
struct Point
{
  int x, y, z;
};
 
int main()
{
  struct Point p1 = {.y = 0, .z = 1, .x = 2};
  printf("%d %d %d", p1.x, p1.y, p1.z);
  return 0;
}

 

Answer: B

No answer description available for this question.

Enter details here

89.

What will be the output of the following C code?

#include
enum sanfoundry
{
    a,b,c=5
};
int main()
{
    enum sanfoundry s;
    b=10;
    printf("%d",b);
}

 

Answer: A

The above code results in an error. This is because it is not possible to change the values of enum constants. In the code shown above, the statement: b=10; causes the error.

Enter details here

90.

What will be the output of the following C code?

#include
enum sanfoundry
{
    a=1,b,c,d,e
};
int main()
{
    printf("%d",b*c+e-d);
}

 

Answer: B

Since arithmetic operations are allowed on enum constants, hence the expression given is evaluates. b*c+e-d = 2*3+5-4 = 6+5-4 = 7

Enter details here

Loading…
Tags: Structures, Unions, Enums Questions and Answers || Structures, Unions, Enums MCQ Questions and Answers || Structures, Unions, Enums GK Questions and Answers || Structures, Unions, Enums GK MCQ Questions || Structures, Unions, Enums Multiple Choice Questions and Answers || Structures, Unions, Enums GK || GK on Structures, Unions, Enums || C Programming Questions and Answers || C Programming MCQ Questions and Answers || C Programming GK Questions and Answers || GK on C Programming