C Programming Quiz

Quiz for C (Structures and Unions)

Time left: 300 seconds

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;
}                     


Select Your Option

In structure ,value cannot be defined.

Q.2. Size of structure depends upon

Select Your Option

Q.3. Size of Union depends upon

Select Your Option

Q.4. Which of the following is a collection of different data types?

Select Your Option

structure has the capability to store data of multiple datatypes

Q.5. Which of the following cannot be a structure member?

Select Your Option

It can only store individual data members,not functions

Q.6. What is the correct syntax to declare a function func() which receives an array of structure in function?

Select Your Option

Q.7. The correct statement below for Union is

Select Your Option

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;
}                     


Select Your Option

Structure cannot contain static members

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];
};                      


Select Your Option

Here largest member is char array. Char takes 1 byte and hence total is 10 bytes

Q.10. Members of a union are accessed using

Select Your Option

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; 
}                       


Select Your Option

Structure variable cannot be assigned

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);
}                       


Select Your Option

Value of variable no is defined using the. Operator and printed

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;
}                       


Select Your Option

This is another method to define multiple values

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;
}                      


Select Your Option

Structure size is equal to sum of size of members.

Q.15. Which of the following is correct syntax for defining struct

Select Your Option

Instructions:-

  1. This Quiz is based on the concepts of Structures and Unions in C
  2. Each correct answer will carry 2 points
  3. Once an option is selected you cannot select any other, So choose wisely
  4. Do not refresh the page as it will reset the quiz
  5. Once the time is up the quiz will automatically get submitted with no of Question responded
  6. Your total score alongwith your name will be shown after submission of the Quiz
  7. Wish you ALL THE BEST 👍👍

START

Results:-

Hi




Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post