Curioustab
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Structures, Unions, Enums Questions
Point out the error in the program? struct emp { int ecode; struct emp *e; };
Point out the error in the program? #include<stdio.h> int main() { struct a { float category:5; char scheme:4; }; printf("size=%d", sizeof(struct a)); return 0; }
Point out the error in the program? #include<stdio.h> #include<string.h> void modify(struct emp*); struct emp { char name[20]; int age; }; int main() { struct emp e = {"Sanjay", 35}; modify(&e); printf("%s %d", e.name, e.age); return 0; } void modify(struct emp *p) { p ->age=p->age+2; }
Point out the error in the program in 16-bit platform? #include<stdio.h> int main() { struct bits { int i:40; }bit; printf("%d\n", sizeof(bit)); return 0; }
Nested unions are allowed
A structure can be nested inside another structure.
Union elements can be of different sizes.
The '->' operator can be used to access structures elements using a pointer to a structure variable only
Which of the following statement is True?
The '.' operator can be used access structure elements using a structure variable.
A union cannot be nested in a structure
Bit fields CANNOT be used in union.
one of elements of a structure can be a pointer to the same structure.
A structure can contain similar or dissimilar elements
It is not possible to create an array of pointer to structures.
If a char is 1 byte wide, an integer is 2 bytes wide and a long integer is 4 bytes wide then will the following structure always occupy 7 bytes? struct ex { char ch; int i; long int a; };
Can we have an array of bit fields?
size of union is size of the longest element in the union
Can a structure can point to itself?
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);
1
2
3