Quiz for C (Structures and Unions)
Q.1. Output of following program
#include<stdio.h>
int main()
{
struct st;
{
int a = 5;
char name[] = "Randomname";
};
struct st *ptr;
printf("%d ", ptr->a);
printf("%s", ptr->name);
getchar();
return 0;
}
Q.2. Size of structure depends upon
Q.3. Size of Union depends upon
Q.4. Which of the following is a collection of different data types?
Q.5. Which of the following cannot be a structure member?
Q.6. What is the correct syntax to declare a function func() which receives an array of structure in function?
Q.7. The correct statement below for Union is
Q.8. Output of following program
#include<stdio.h>
struct cont
{
int a;
static int b;
};
int main()
{
printf("%d", sizeof(struct cont));
return 0;
}
Q.9. The size of the following union, assuming that int occupies 4 bytes of memory is
union demo
{
float a;
int b;
char c[10];
};
Q.10. Members of a union are accessed using
Q.11. Output of following code
#include<stdio.h>
struct struc
{
int x;
struct struc link;
};
int main()
{
struct struc temp;
temp.x = 10;
temp.link= temp;
printf("%d", temp.link.x);
return 0;
}
Q.12. Output of following code
#include <stdio.h>
void main()
{
struct num
{
int no;
char name[20];
};
struct num o;
o.no = 50;
printf("%d", o.no);
}
Q.13. Output of following code
#include<stdio.h>
struct Coord
{
int x, y, z;
};
int main()
{
struct Coord p1 = {.y = 0, .z = 1, .x = 2};
printf("%d %d %d", p1.x, p1.y, p1.z);
return 0;
}
Q.14. Output of following code
#include <stdio.h>
int main()
{
struct sample
{
int a;
int b;
sample *s;
}t;
printf("%d,%d",sizeof(sample),sizeof(t.s));
return 0;
}
Q.15. Which of the following is correct syntax for defining struct
Instructions:-
- This Quiz is based on the concepts of Structures and Unions in C
- Each correct answer will carry 2 points
- Once an option is selected you cannot select any other, So choose wisely
- Do not refresh the page as it will reset the quiz
- Once the time is up the quiz will automatically get submitted with no of Question responded
- Your total score alongwith your name will be shown after submission of the Quiz
- Wish you ALL THE BEST 👍👍
START
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP