Top

Structures, Unions, Enums

51.

What is the output of this program?

#include 
struct test {
    int x;
    char y;
} test;

int main()
{
    test.x = 10;
    test.y = 'A';
    printf("%d %c", test.x,test.y);
    return 0;
}

 

Answer: A

No answer description available for this question

Enter details here

Answer: C

No answer description available for this question.

Enter details here

Answer: C

No answer description available for this question

Enter details here

Answer: D

No answer description available for this question.

Enter details here

55.

Which properly declares a variable of struct foo?

Answer: B

No answer description available for this question

Enter details here

56.

Point out the error (if any) in the following C code?

#include
enum hello
{
    a,b,c;
};
main()
{
    enum hello m;
    printf("%d",m);
}

 

Answer: B

In the above code, there is a semi colon given at the end of the list of variables. This results in an error. Semi colon is to be put only after the closing brace of the enum, not after the list of variables.

Enter details here

Answer: A

No answer description available for this question

Enter details here

58.

What is the output of this program?

#include 
struct student
{
  int no = 5;
  char name[20];
};
void main()
{
  struct student s;
  s.no = 8;
  printf("hello");
}

 

Answer: B

No answer description available for this question

Enter details here

59.

What is the output of this program?

#include 
int main(){
   struct simp 
 {
  int i = 6;
  char city[] = "chennai";
 };
 struct simp s1;
 printf("%d",s1.city);
 printf("%d", s1.i);
    return 0;
}

 

Answer: D

Compilation Error: Cannot initialize a class member here When we declared members in struture, it just tells the compiler about their presence. There is no memory allocated for that members. So we can't intialize structure members.

Enter details here

60.

What will be the output of the following C code?

#include
enum class
{
    a,b,c
};
enum class m;
main()
{
    printf("%d",sizeof(m));
}

 

Answer: B

No answer description available for this question

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