Note 1

Take Note:

Take a note while surfing.





Note With Ink

Give your Note a Colorful Tag.




Easy to Access

Stay on same information and in Sync wherever you are.

Note 2

Take Note:

Organize your information,It may take Shape.





Think With Ink

Differ your Content by Color.




Easy to Access

Easy to pull up your content from anywhere anytime.

Note 3

Take Note:

Don't Let information to miss,Because it take shape





Note With Ink

Simple an Easy Way to take a note.




Easy to Access

Get the same in next visit.


Please wait...

  Take Quiz (Monsoon) Beta Version !!
  Do You have Qs. in your Mind ??? Ask it as Qs. or MCQs or create it as polling Live Now !!

C Programming :: Structures, Unions, Enums

Home > C Programming > Structures, Unions, Enums > General Questions

1 / 43

 What is the output of the following program ?

#include
int main() {
union {
int a;
int b;
int c;
} u,v;
u.a = 10;
u.b = 20;
printf("%d %d \n",u.a,u.b);
return 0;
}

Answer: Option A

Explanation:

Here is no explanation for this answer

Workspace


Tags:  No Tags on this question yet!

2 / 43

 What is the output of the following problem ?

#include

struct {
int x;
int y;
union {
int id_no;
char *name;
}b;
}s,*st;
int main()
{
st = &s;
st->x=10;
st->b.id_no = 101;
printf("%d %d\n",s.x,s.b.id_no);
return 0;
}

Answer: Option C

Explanation:

Here is no explanation for this answer

Workspace


Tags:  No Tags on this question yet!

3 / 43

 What is the output of the following program ?

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

Answer: Option D

Explanation:

Initialization should not be done for structure members inside the structure declaration

Workspace


Tags:  No Tags on this question yet!

4 / 43

 What is the output of the following 'C' program ?

#include
struct myStruct{
int a;
char b;
}*ptr;
int main(){
struct myStruct ms={400,'A'};
printf("%d %d",ptr->a,ptr->b);
return 0;
}

Answer: Option D

Explanation:

Here is no explanation for this answer

Workspace


Tags:  No Tags on this question yet!

5 / 43

 What is the output of the following 'C' program ?

#include
typedef struct stu1{
char name1[6];
char name2[6];
double marks;
}STU1;
void main(){
STU1 s1={"rohit","kumar",87.43},*p1;
char *p;
p1=&s1;
p=memchr(p1,'u',sizeof(STU1));
printf("%s",p);
}

Answer: Option C

Explanation:

Here is no explanation for this answer

Workspace


Tags:  No Tags on this question yet!

6 / 43

 What is the output of the following 'C' program?

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

Answer: Option C

Explanation:

You should not initialize variables in declaration

Workspace


Tags:  No Tags on this question yet!

7 / 43

 What is the output of the following 'C' program?

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

Answer: Option B

Explanation:

The structure yy is nested within structure xx.
Hence, the elements are of yy are to be accessed through the instance of structure xx, which needs an instance of yy to be known.
If the instance is created after defining the structure the compiler will not know about the instance relative to xx. Hence for nested structure yy you have to declare member.

Workspace


Tags:  No Tags on this question yet!

8 / 43

 What is the output of the following 'C' program?

#include
enum colors {BLACK,BLUE,GREEN,YELLOW};
int main()
{
printf("%d..%d..%d..%d",BLACK,BLUE,GREEN,YELLOW);
return 0;
}

Answer: Option D

Explanation:

enum assigns numbers starting from 0, if not explicitly defined.

Workspace


Tags:  No Tags on this question yet!

9 / 43

 What is the output of the following 'C' program?

#include
enum colors {BLACK,BLUE=2,GREEN,YELLOW};
int main()
{
printf("%d..%d..%d..%d",BLACK,BLUE,GREEN,YELLOW);
return 0;
}

Answer: Option A

Explanation:

Here is no explanation for this answer

Workspace


Tags:  No Tags on this question yet!

10 / 43

 What is the output of the following 'C' program?

#include
enum colors {BLACK,BLUE=-2,GREEN,YELLOW};
int main()
{
printf("%d..%d..%d..%d",BLACK,BLUE,GREEN,YELLOW);
return 0;
}

Answer: Option B

Explanation:

Here is no explanation for this answer

Workspace


Tags:  No Tags on this question yet!