Top

Structures, Unions, Enums

1.

What will be the size of the following structure?

struct demo{
  int a;
  char b;
  float c;
}

 

Answer: A

No answer description available for this question

Enter details here

2.

Which of the following operators can be applied on structure variables?

Answer: B

No answer description available for this question.

Enter details here

3.

Number of bytes in memory taken by the below structure is

#include 
struct test
{
  int k;
  char c;
};

 

Answer: A

Number of bytes in memory taken by the below structure is Multiple of integer size

Enter details here

4.

What will be the output of the following C code?

#include
#define MAX 4
enum sanfoundry
{
    a,b=3,c
};
main()
{
    if(MAX!=c)
        printtf("hello");
    else
        printf("welcome");
}

 

Answer: C

The output will be welcome. The value of the macro MAX is 4. Since 4 is equal to the value of c, welcome is printed.

Enter details here

5.

What will be the output of the following C code if input given is 2?

#include
enum day
{
    a,b,c=5,d,e
};
main()
{
    printf("Enter the value for a");
    scanf("%d",a);
    printf("%d",a);
}

 

Answer: D

The code shown above results in an error. This is because memory is not allocated for constants in enum. Thereore ampersand(&) cannot be used with them. Also, a value has already been assigned to ‘a’, which cannot be changed.

Enter details here

Answer: B

No answer description available for this question

Enter details here

Answer: A

No answer description available for this question.

Enter details here

8.

What is the output of this program?

#include          
void main()
{
struct demo{
    char * a;
    int n;
};

struct demo p = {"hello", 2015};
struct demo q = p;
printf("%d", printf("%s",q.a));
}

 

Answer: C

No answer description available for this question

Enter details here

9.

What will be the output of the program if it is executed like below?
cmd> sample

/* sample.c */
#include

int main(int argc, char **argv)
{
    printf("%s\n", argv[argc-1]);
    return 0;
}

 

Answer: B

No answer description available for this question.

Enter details here

10.

Members of a union are accessed as________________.

Answer: C

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