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.

C Programming :: Structures, Unions, Enums

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

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

#include
struct point
{
int x;
int y;
};
struct point origin,*pp;
int main()
{
pp=&origin;
printf("origin is(%d%d)\n",(*pp).x,(*pp).y);
printf("origin is (%d%d)\n",pp->x,pp->y);
return 0;
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option C

Explanation:

pp is a pointer to structure. we can access the elements of the structure either with arrow mark or with indirection operator.
Since structure point is globally declared x & y are initialized as zeroes

Workspace

Tags:

No Tags on this question yet!

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

#include
void main()
{
struct emp
{
char name [20];
int age;
float sal;
};
struct emp e = {"Tiger"};
printf("\n%d %f", e.age, e.sal);
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option B

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

13. What error are you likely to get when you run the following program?

#include
void main() {
struct emp
{
char name[20];
float sal;
};
struct emp e[10];
int i;
for(i=0;i <= 1; i++)
scanf("%s%f", e[i].name, & e[i].sal);
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option D

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

14. What is the output of the following program ?

#include
struct aaa{
struct aaa *prev;
int i;
struct aaa *next;
};
void main()
{
struct aaa abc,def,ghi,jkl;
int x=100;
abc.i=0;
abc.prev=&jkl;
abc.next=&def;
def.i=1;def.prev=&abc;
def.next=&ghi;
ghi.i=2;ghi.prev=&def;
ghi.next=&jkl; jkl.i=3;
jkl.prev=&ghi;
jkl.next=&abc;
x=abc.next->next->prev->next->i;
printf("%d",x);
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option D

Explanation:

above all statements form a double circular linked list;

abc.next->next->prev->next->i

this one points to "ghi" node the value of at particular node is 2.

Workspace

Tags:

No Tags on this question yet!

15. What is the output of the following program ?

#include
void main()
{
enum {i=10,j=20,k=50};
printf("%d",++k);
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option A

Explanation:

Enumeration constants cannot be modified, so you cannot apply ++.

Workspace

Tags:

No Tags on this question yet!

16. What is the output for the program given below

#include
typedef enum errorType{warning, error, exception,}error;
void main()
{
error g1;
g1=1;
printf("%d",g1);
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option D

Explanation:

previous definition of "error" is in the below line.
typedef enum errorType{warning, error, exception,}error;
^

Workspace

Tags:

No Tags on this question yet!

17. What is the output of the following program ?

#include
typedef struct error
{
int warning, error, exception;
}error;
void main()
{
error g1;
g1.error=1;
printf("%d",g1.error);
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option A

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

18. What will be output of the following "c" code?

#include
void main()
{
struct date;
struct student
{
char name[30];
int rollno;
struct date dob;
}stud;

struct date
{
int day,month,year;
};
scanf("%s%d%d%d",stud.rollno,&student.dob.day,&student.dob.month,&student.dob.year);
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option B

Explanation:

Only declaration of struct date is available inside the structure definition of 'student' but to have a variable of type struct date the definition of the structure is required.

Workspace

Tags:

No Tags on this question yet!

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

#include
int main()
{
struct sample
{
int a:6;
int b:12;
char s;
}st;

struct name
{
int a:28;
int b:12;
char ch;
}st1;

printf("%d %d",sizeof(st),sizeof(st1));
return 0;
}
Note: int takes 4 bytes, char takes 1 byte. ?

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option A

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

20. What will be the size of these structures?

#include
struct S1 {
char c;
int i[2];
double v;
} SA1;
struct S2 {
double x;
int i[2];
char c;
} SA2;
int main()
{
printf("\n sizeof S1 %d : Sizeof S2 %d ",sizeof(SA1),sizeof(SA2));
return 0;
}
Note:char takes 1 byte, int takes 4 bytes, double takes 8 bytes

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option B

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!