logo

CuriousTab

CuriousTab

Discussion


Home C Programming Structures, Unions, Enums See What Others Are Saying!
  • Question
  • Nested unions are allowed


  • Options
  • A. True
  • B. False

  • Correct Answer
  • True 


  • More questions

    • 1. Can you combine the following two statements into one?
      char *p;
      p = (char*) malloc(100);
      

    • Options
    • A. char p = *malloc(100);
    • B. char *p = (char) malloc(100);
    • C. char *p = (char*)malloc(100);
    • D. char *p = (char *)(malloc*)(100);
    • Discuss
    • 2. How many bytes are occupied by near, far and huge pointers (DOS)?

    • Options
    • A. near=2 far=4 huge=4
    • B. near=4 far=8 huge=8
    • C. near=2 far=4 huge=8
    • D. near=4 far=4 huge=8
    • Discuss
    • 3. Can a structure can point to itself?

    • Options
    • A. Yes
    • B. No
    • Discuss
    • 4. What will be the output of the program if the array begins 1200 in memory?
      #include<stdio.h>
      
      int main()
      {
          int arr[]={2, 3, 4, 1, 6};
          printf("%u, %u, %u\n", arr, &arr[0], &arr);
          return 0;
      }
      

    • Options
    • A. 1200, 1202, 1204
    • B. 1200, 1200, 1200
    • C. 1200, 1204, 1208
    • D. 1200, 1202, 1200
    • Discuss
    • 5. What will be the output of the program?
      #include<stdio.h>
      
      int main()
      {
          union a
          {
              int i;
              char ch[2];
          };
          union a u;
          u.ch[0]=3;
          u.ch[1]=2;
          printf("%d, %d, %d\n", u.ch[0], u.ch[1], u.i);
          return 0;
      }
      

    • Options
    • A. 3, 2, 515
    • B. 515, 2, 3
    • C. 3, 2, 5
    • D. 515, 515, 4
    • Discuss
    • 6. What will be the output of the program given below in 16-bit platform?
      #include<stdio.h>
      
      int main()
      {
          enum value{VAL1=0, VAL2, VAL3, VAL4, VAL5} var;
          printf("%d\n", sizeof(var));
          return 0;
      }
      

    • Options
    • A. 1
    • B. 2
    • C. 4
    • D. 10
    • Discuss
    • 7. What will be the output of the program?
      #include<stdio.h>
      
      int main()
      {
          struct byte
          {
              int one:1;
          };
          struct byte var = {1};
          printf("%d\n", var.one);
          return 0;
      }
      

    • Options
    • A. 1
    • B. -1
    • C. 0
    • D. Error
    • Discuss
    • 8. Point out the error in the program?
      #include<stdio.h>
      
      int main()
      {
          struct bits
          {
              float f:2;
          }bit;
      
          printf("%d\n", sizeof(bit));
          return 0;
      }
      

    • Options
    • A. 4
    • B. 2
    • C. Error: cannot set bit field for float
    • D. Error: Invalid member access in structure
    • Discuss
    • 9. Point out the error in the program?
      #include<stdio.h>
      
      int main()
      {
          struct emp
          {
              char n[20];
              int age;
          };
          struct emp e1 = {"Dravid", 23};
          struct emp e2 = e1;
          if(e1 == e2)
              printf("The structure are equal");
          return 0;
      }
      

    • Options
    • A. Prints: The structure are equal
    • B. Error: Structure cannot be compared using '=='
    • C. No output
    • D. None of above
    • Discuss
    • 10. Will the following code work?
      #include<stdio.h>
      #include<malloc.h>
      
      struct emp
      {
          int len;
          char name[1];
      };
      int main()
      {
          char newname[] = "Rahul";
          struct emp *p = (struct emp *) malloc(sizeof(struct emp) -1 +
                          strlen(newname)+1);
      
          p->len = strlen(newname);
          strcpy(p -> name, newname);
          printf("%d %s\n", p->len, p->name);
          return 0;
      }
      

    • Options
    • A. Yes
    • B. No
    • Discuss


    Comments

    There are no comments.

Enter a new Comment