Discussion
What will be the output of following program ?
#include <stdio.h>
int main()
{
typedef int AAA,BBB,CCC,DDD;
AAA aaa=10;
BBB bbb=20;
CCC ccc=30;
DDD ddd=40;
printf("%d,%d,%d,%d",aaa,bbb,ccc,ddd);
return 0;
}
Answer: C
Correct answer: 10,20,30,40
A single typedef can declare several names, so AAA, BBB, CCC and DDD all become aliases for int. They are four names for one type, not four distinct types, so the four variables are ordinary independent ints holding 10, 20, 30 and 40. Sharing an alias creates no relationship between the variables at all.
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development