Structure And Union - Study Mode

[#96] 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
", ptrary[1]->name)

return 0

}
Correct Answer

(C) Undefined behaviour

[#97] What will be the output of the following C code? #include <stdio.h>
struct student
{
char a[5]

}

void main()
{
struct student s[] = {"hi", "hey"}

printf("%c", s[0].a[1])

}
Correct Answer

(B) i

[#98] 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))

}
Correct Answer

(C) 8

[#99] 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
", sizeof(p))

}
Correct Answer

(D) sizeof(int)

[#100] 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)

}
Correct Answer

(B) Compile time error