Exercise: Structures Unions Enums

Questions for: Structures Unions Enums

By default structure variable will be of auto storage class
A:
Yes
B:
No
C:
D:
Answer: A
No answer description is available. Let's discuss.
Is there easy way to print enumeration values symbolically?
A:
Yes
B:
No
C:
D:
Answer: B
You can write a function of your own to map an enumeration constant to a string.
A pointer union CANNOT be created
A:
Yes
B:
No
C:
D:
Answer: B
No answer description is available. Let's discuss.
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;
}
A:
Yes
B:
No
C:
D:
Answer: A
The program allocates space for the structure with the size adjusted so that the name field can hold the requested name.
The elements of union are always accessed using & operator
A:
Yes
B:
No
C:
D:
Answer: B
No answer description is available. Let's discuss.
Ad Slot (Above Pagination)
Quiz