Discussion
What will be the output of the program in 16-bit platform (Turbo C under DOS) ?
#include <stdio.h>
int main()
{
printf("%d, %d, %d", sizeof(3.0f), sizeof('3'), sizeof(3.0));
return 0;
}
Answer: B
Correct answer: 4, 2, 8
On a 16-bit Turbo C target: 3.0f is a float, 4 bytes; '3' is a character constant, which has type int in C, so 2 bytes on that platform - not 1; and 3.0 with no suffix is a double, 8 bytes. The character constant is the trap: it is an int in C and a char only in C++.
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