logo

CuriousTab

CuriousTab

Structures, Unions, Enums problems


  • 1. Is there easy way to print enumeration values symbolically?

  • Options
  • A. Yes
  • B. No
  • Discuss
  • 2. The elements of union are always accessed using & operator

  • Options
  • A. Yes
  • B. No
  • Discuss
  • 3. Is it necessary that the size of all elements in a union should be same?

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

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

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

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

First 2 3 4 5