C Language - Structures,Unions

You Are Here :: Home > C Language > Structures,Unions General Questions

 
19.

#include

main()
{
struct xx
{
int x=3;
char name[]="hello";
};
struct xx *s=malloc(sizeof(struct xx));
printf("%d",s->x);
printf("%s",s->name);
}

A. 3 B. Hello
C. 3 Hello D. Compiler Error




20.

enum colors {BLACK,BLUE,GREEN}

main()
{
printf("%d..%d..%d",BLACK,BLUE,GREEN);
return(1);
}

A. 1..2..4 B. 0..1..2
C. 2..1..0 D. 1..1..1




21.

#include

main()
{
struct xx
{
int x;
struct yy
{
char s;
struct xx *p;
};
struct yy *q;
};
}

A. x B. y
C. s D. Compiler Error




22.

What will be output if you will execute following code?

#include
union address{
char *name;
char street[10];
int pin;
};
int main(){
union address emp,*p;
emp.name="sh\0alu";
p=&emp;
printf("%s%s",p->name,(*p).name);
return 0;
}

A. sa sh B. sh aa
C. sh sa D. sh sh




23.

What will be output if you will execute following code?

#include
struct address{
char *name;
char street[10];
int pin;
}ex={"G.shalini","A-1",456003},*p=&ex;
int main(){
printf("%s%s",p->name,(*p).street);
return 0;
}

A. shalini B. shalini.G
C. G.shalini A-1 D. A-1 G.shalini




24.

What is the output of this C code?

#include
union utemp
{
int a;
double b;
char c;
}u;
int main()
{
u.c = 'A';
u.a = 1;
printf("%d", sizeof(u));
}
The output will be: (Assuming size of char = 1, int = 4, double = 8)

A. 1 B. 4
C. 8 D. 13




« previous

1

2

3

4

5

6

7

8

9

...

next »

 
 
 



© 2013 freshersindia.in ® | Copyrights | Terms & Conditions
   Designed by Freshers India
Catch Us on