51.
What will be the output of the following C code?
#include <stdio.h>
struct point
{
    int x;
    int y;
};
void foo(struct point*);
int main()
{
    struct point p1[] = {1, 2, 3, 4, 5};
    foo(p1);
}
void foo(struct point p[])
{
    printf("%d %d\n", p->x, (p + 2)->y);
}

52.
What will be the output of the following C code?
#include <stdio.h>
struct student
{
    char a[];
};
void main()
{
    struct student s;
    printf("%d", sizeof(struct student));
}

54.
Which is the correct syntax to use typedef for struct?

typedef struct temp
{
    int a;
}TEMP;

typedef struct
{
    int a;
 }TEMP;

struct temp
{
    int a;
};
typedef struct temp TEMP;

55.
What will be the output of the following C code?
#include <stdio.h>
struct point
{
    int x;
    int y;
};
struct notpoint
{
    int x;
    int y;
};
struct point foo();
int main()
{
    struct point p = {1};
    struct notpoint p1 = {2, 3};
    p1 = foo();
    printf("%d\n", p1.x);
}
struct point foo()
{
    struct point temp = {1, 2};
    return temp;
}

56.
What will be the output of the following C code?
#include <stdio.h>
struct student
{
    char *name;
};
void main()
{
    struct student s[2], r[2];
    s[1] = s[0] = "alan";
    printf("%s%s", s[0].name, s[1].name);
}

57.
What will be the output of the following C code?
#include <stdio.h>
int main()
{
    struct p
    {
        char *name;
        struct p *next;
    };
    struct p p, q;
    p.name = "xyz";
    p.next = NULL;
    ptrary[0] = &p;
    strcpy(q.name, p.name);
    ptrary[1] = &q;
    printf("%s\n", ptrary[1]->name);
    return 0;
}

59.
What will be the output of the following C code? (Assuming size of char = 1, int = 4, double = 8)
#include <stdio.h>
union utemp
{
    int a;
    double b;
    char c;
}u;
int main()
{
    u.c = 'A';
    u.a = 1;
    printf("%d", sizeof(u));
}

60.
What will be the output of the following C code?
#include <stdio.h>
union
{
    int x;
    char y;
}p;
int main()
{
    p.x = 10;
    printf("%d\n", sizeof(p));
}

Read More Section(Structure and Union)

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