logo

CuriousTab

CuriousTab

Discussion


Home C Programming Structures, Unions, Enums Comments

  • Question
  • Is it necessary that the size of all elements in a union should be same?


  • Options
  • A. Yes
  • B. No

  • Correct Answer
  • No 


  • Structures, Unions, Enums problems


    Search Results


    • 1. The elements of union are always accessed using & operator

    • Options
    • A. Yes
    • B. No
    • Discuss
    • 2. Is there easy way to print enumeration values symbolically?

    • Options
    • A. Yes
    • B. No
    • Discuss
    • 3. If the following structure is written to a file using fwrite(), can fread() read it back successfully?
      struct emp
      {
          char *n;
          int age;
      };
      struct emp e={"CuriousTab", 15};
      FILE *fp;
      fwrite(&e, sizeof(e), 1, fp);
      

    • Options
    • A. Yes
    • B. No
    • Discuss
    • 4. Can a structure can point to itself?

    • Options
    • A. Yes
    • B. No
    • Discuss
    • 5. size of union is size of the longest element in the union

    • Options
    • A. Yes
    • B. No
    • Discuss
    • 6. By default structure variable will be of auto storage class

    • Options
    • A. Yes
    • B. No
    • Discuss
    • 7. Will the following declaration work?
      typedef struct s
      {
          int a;
          float b;
      }s;
      

    • Options
    • A. Yes
    • B. No
    • Discuss
    • 8. 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
    • 9. A pointer union CANNOT be created

    • Options
    • A. Yes
    • B. No
    • Discuss
    • 10. What will be the output of the program if it is executed like below?
      cmd> sample
      /* sample.c */
      #include<stdio.h>
      
      int main(int argc, char **argv)
      {
          printf("%s\n", argv[argc-1]);
          return 0;
      }
      

    • Options
    • A. 0
    • B. sample
    • C. samp
    • D. No output
    • Discuss


    Comments

    There are no comments.

Enter a new Comment