C-Structure & Union Question and Answer
C-Structure & Union Question and Answer
52. Find the correct output
void main ( )
{
struct emp
{
int eid;
char ename[20];
};
struct emp e={010, "Deepak"};
show (e);
}
show (struct {int eid; char ename [20];}e)
{
printf("%0%s", e.eid,e.ename);
}
void main ( )
{
struct emp
{
int eid;
char ename[20];
};
struct emp e={010, "Deepak"};
show (e);
}
show (struct {int eid; char ename [20];}e)
{
printf("%0%s", e.eid,e.ename);
}
- 010
- 010 Deepak
- None of these
- Compilation Error
54. Find the output
void main ( )
{
struct abc
{
char ch[10];
int i;
};
struct abc a=
{"Dear", 10, "Customer", 20};
printf('%s", a.ch);
}
void main ( )
{
struct abc
{
char ch[10];
int i;
};
struct abc a=
{"Dear", 10, "Customer", 20};
printf('%s", a.ch);
}
- Dear
- Customer
- Compilation error
- None of these
55. In the following program p.a. is same as:
struct xxx
{
int a;
int b;
}b={9, 10};
struct xxx
{
int a;
int b;
}b={9, 10};
- p->a
- &p->a
- (&p)->a
- *p.a
56. Find the output
void main ( )
{
struct yyy
{
char ch;
int i;
};
struct yyy y={'1', 1};
xxx (y);
}
xxx (struct yyy y)
{
printf ("%c....%d",y.ch, y.i);
}
void main ( )
{
struct yyy
{
char ch;
int i;
};
struct yyy y={'1', 1};
xxx (y);
}
xxx (struct yyy y)
{
printf ("%c....%d",y.ch, y.i);
}
- No output
- Compilation error
- 1.....1
- None of these
57. Find the output
void main ()
{
struct zzz
{
int i;
int j;
}pqr;
struct zzz *z;
z=&pqr;
z->=100
z->=200;
xxx (z);
}
xxx (int *p)
{
p++;
printf("%d", *p);
}
void main ()
{
struct zzz
{
int i;
int j;
}pqr;
struct zzz *z;
z=&pqr;
z->=100
z->=200;
xxx (z);
}
xxx (int *p)
{
p++;
printf("%d", *p);
}
- 100
- 200
- Compilation error
- None of these
58. Find the output
struct xxx
{
int age;
char name [10];
};
void main ( )
{
struct xxx *p={26, "raja"};
printf('%s", p->name);
}
struct xxx
{
int age;
char name [10];
};
void main ( )
{
struct xxx *p={26, "raja"};
printf('%s", p->name);
}
- raja
- Garbage
- Null pointer assignment
- Compiltion error
59. Find the output
union complex
{
int i;
float real;
};
void main( )
{
union complex c={2};
printf ("%d %f", c.i,c.real);
}
union complex
{
int i;
float real;
};
void main( )
{
union complex c={2};
printf ("%d %f", c.i,c.real);
}
- 2 2.000
- 2 0
- 2 0.0000
- Garbage value
60. Find the output
struct str
{
int i;
float f;
};
union uti
{
int i;
float f;
};
void main ( )
{
printf("%d", sizeof (struct str) - sizeof (union uti));
}
struct str
{
int i;
float f;
};
union uti
{
int i;
float f;
};
void main ( )
{
printf("%d", sizeof (struct str) - sizeof (union uti));
}
- Error: Structure and union variable are not declared
- Error: Same members are not declared for both structure and union.
- 2
- 0