41.
What will be the output of the following C code?
#include <stdio.h>
void main()
{
    struct student
    {
        int no;
        char name[20];
    };
    struct student s;
    no = 8;
    printf("%d", no);
}

42.
What will be the output of the following C code?
#include <stdio.h>
struct p
{
    int x;
    char y;
};
int main()
{
    struct p p1[] = {1, 92, 3, 94, 5, 96};
    struct p *ptr1 = p1;
    int x = (sizeof(p1) / sizeof(struct p));
    printf("%d %d\n", ptr1->x, (ptr1 + x - 1)->x);
}

43.
What will be the output of the following C code?
#include <stdio.h>
struct point
{
    int x;
    int y;
};
int main()
{
    struct point p = {1};
    struct point p1 = {1};
    if(p == p1)
        printf("equal\n");
    else
        printf("not equal\n");
}

44.
Which of the following structure declaration doesn't require pass-by-reference?

struct{int a;}s;
main(){}

struct temp{int a;};
main(){
    struct temp s;
}

struct temp{int a;};
main(){}
struct temp s;

45.
How many bytes in memory taken by the following C structure?
#include <stdio.h>
struct test
{
    int k;
    char c;
};

46.
What will be the output of the following C code?
#include <stdio.h>
typedef struct p
{
    int x, y;
}k;
int main()
{
    struct p p = {1, 2};
    k k1 = p;
    printf("%d\n", k1.x);
}

48.
What will be the output of the following C code?
#include <stdio.h>
struct student
{
    char *name;
};
struct student fun(void)
{
    struct student s;
    s.name = "alan";
    return s;
}
void main()
{
    struct student m = fun();
    printf("%s", m.name);
}

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

50.
What will be the output of the following C code?
#include <stdio.h>
struct student
{
    char *c;
};
void main()
{
    struct student *s;
    s->c = "hello";
    printf("%s", s->c);
}

Read More Section(Structure and Union)

Each Section contains maximum 100 MCQs question on Structure and Union. To get more questions visit other sections.