Structure & Union Questions and Answers
Practice ModeShowing 10 of 95 questions
Q1
The storage is allocated to structure only when
Answer: Option B
Q2
Find the output
struct date
{
int day, month, year;
};
void main ( )
{
struct date today={3, 7, 6, 2007};
printf("%d% d% %d", today. day, today. month, today. year);
}
Answer: Option C
Q3
Find the output
struct faculty
{
int fid;
int fage;
char fname [20];
}
1ca;
void main ( )
{
static struct dilip={231, 32, "mahesh"};
printf("%d%d%ds", diip.fid);
}
Answer: Option D
Q4
Find the output
struct emp
{
int age;
char name [20];
float sal;
}
e={23, "bhagya", 8000.000};
void main ( )
{
printf("%d%d%d", e.age, e.name, e.sal);
}
Answer: Option C
Q5
Can the member name of the structure be same as the name of a variable of that structure?
Answer: Option A
Q6
Find the bug in the following program
1. struct emp{
2. int eid;
3. int age;
4. char n[10];
5. float sal;
6. double eid;
7. struct emp *p;
8. }*q;
Answer: Option C
Q7
Find the bug in the following program?
1. struct dept {
2. int d;
3. char dname[20];
4. float income;
5. }dn={121,"finance", 20.34};
6. void main ( ) {
7. ++dn. income;
8. printf("%d %s %f", dn.dn,
dn. dname, dn.income);}
Answer: Option D
Q8
Find the output.
structr st
{
int x;
show ( );
}:
struct st s;
show ( )
{
printf ("%d', s.x);
}
void main ( )
{
s.x=10;
s.show();
}
Answer: Option C
Q9
Find the correct one from the following three compositions
I. typedef struct
{
int month, day, year;
} date;
void main ( )
{
int ano;
date payment;
} record;
record employee[100];
II. typedef struct date
{
int month, day, year;
};
void main ( )
{
int ano;
struct data payment;
}record [100];
record employee;
III. typedef struct
{
int month, day, year;
} date;
void main ( )
{
int ano
data payment;
}
employee [100];
Answer: Option B
Q10
Find the output.
typedef struct bitfield
{
int a:7;
char b:8;
unsigned int c:15;
}bit;
void main ( )
{
bit b1;
printf("%d %d %d", sizeof (b1.a),
sizeof (b1.b), sizeof (b1.c);
}
Answer: Option D