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\n", *p.x++);
}
#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\n", *p.x++);
}
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\n", p.ptr->x);
return 0;
}
#include <stdio.h>
struct p
{
int x;
char y;
struct p *ptr;
};
int main()
{
struct p p = {1, 2, &p};
printf("%d\n", p.ptr->x);
return 0;
}
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);
}
#include <stdio.h>
struct student
{
char *c;
};
void main()
{
struct student m;
struct student *s = &m;
s->c = "hello";
printf("%s", s->c);
}
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}};
}
#include <stdio.h>
struct temp
{
int a;
int b;
int c;
};
main()
{
struct temp p[] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
}
85. Which of the following operation is illegal in structures?
86. The correct syntax to access the member of the ith structure in the array of structures is?
Assuming: struct temp
{
int b;
}s[50];
Assuming: struct temp
{
int b;
}s[50];
87. 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(ptr1));
if (x == 1)
printf("%d\n", ptr1->x);
else
printf("false\n");
}
#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(ptr1));
if (x == 1)
printf("%d\n", ptr1->x);
else
printf("false\n");
}
88. What will be the output of the following C code?
#include <stdio.h>
struct student
{
char *c;
struct student *point;
};
void main()
{
struct student s;
struct student m;
m.point = s;
(m.point)->c = "hey";
printf("%s", s.c);
}
#include <stdio.h>
struct student
{
char *c;
struct student *point;
};
void main()
{
struct student s;
struct student m;
m.point = s;
(m.point)->c = "hey";
printf("%s", s.c);
}
89. What will be the output of the following C code?
#include <stdio.h>
union stu
{
int ival;
float fval;
};
void main()
{
union stu r;
r.ival = 5;
printf("%d", r.ival);
}
#include <stdio.h>
union stu
{
int ival;
float fval;
};
void main()
{
union stu r;
r.ival = 5;
printf("%d", r.ival);
}
90. What will be the output of the following C code?
#include <stdio.h>
union
{
int x;
char y;
}p;
int main()
{
p.y = 60;
printf("%d\n", sizeof(p));
}
#include <stdio.h>
union
{
int x;
char y;
}p;
int main()
{
p.y = 60;
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.