Structure And Union - Study Mode

[#81] 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}

foo(&p1)

}
void foo(struct point *p)
{
printf("%d
", *p.x++)

}
Correct Answer

(A) Compile time error

[#82] What will be the output of the following C code? #include <stdio.h>
struct p
{
int x

char y

struct p *ptr

}

int main()
{
struct p p = {1, 2, &p}

printf("%d
", p.ptr->x)

return 0

}
Correct Answer

(C) 1

[#83] What will be the output of the following C code? #include <stdio.h>
struct student
{
char *c

}

void main()
{
struct student m

struct student *s = &m
s->c = "hello"

printf("%s", s->c)

}
Correct Answer

(A) hello

[#84] Comment on the output of the following C code. #include <stdio.h>
struct temp
{
int a

int b

int c

}

main()
{
struct temp p[] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}

}
Correct Answer

(A) No Compile time error, generates an array of structure of size 3

[#85] The correct syntax to access the member of the ith structure in the array of structures is? Assuming: struct temp
{
int b

}s[50]

Correct Answer

(D) s[i].b