Structure & Union Questions and Answers
Practice ModeShowing 10 of 95 questions
Q11
How to access eid in the following structure?
struct employee
{
int eid;
char name[23];
float salary;
}
emp={278,"p.das", 5000.000}, *p=&emp;
I. *p->eid
II. p.eid
III. (*p).eid
IV.. (*p)->eid
Answer: Option B
Q12
Find the bug in the following jprogram
1. int a=15;
2. struct independence{
3. int *p;
4. char mon [10];
5. int year;
6. }data={&a "august", 1947}, *p=&date;
7. void main ( ) {
8. ++*p;
9.printf("%d", *p->q;
10. }
Answer: Option A
Q13
Find the bug in the program
1. typedef struct {
2. char *name;
3. int ano;
4. float bal;
5. }record;
6. void main ( ) {
7. void change (record *p);
8. static record
emp={"abc", 111, 3000.000};
9. change (emp);
10. void change (record *p) {
11. p->name="xyz", p->ano=222,p-> ball=6000.000;
12. return;}
Answer: Option C
Q14
State the true statement.
Answer: Option D
Q15
Find the output
struct dist
{
char s[8];
char *str;
};
void main ( )
{
struct dist d={"udaipur", "Jaipur"}
printf ("%c%c", d.s[0],++(*d.str));
}
Answer: Option C
Q16
Find the output
struct state
{
char * dname;
int dcode;
struct state *p;
};
void main ( )
{
static struct state q[ ]=
{{"Jajpur", 10, q+1},
{"jaipur", 20, q+2},
{"dimapur", 30,q}};
printf ("%s %s", q[0].dname,q[2].p->name);}
Answer: Option D
Q17
Find the output.
void main ( )
{
struct nm
{
int roll [5];
char aneme[10];
};
printf("5d", sizeof(nm));
}
Answer: Option D
Q18
Self referential structure
Answer: Option D
Q19
Find the incorrect one regarding passing structure to a function,
Answer: Option B
Q20
Choose the correct one
Answer: Option D