Discussion
Comment on the output of this C code?
int const print()
{
printf("AllIndiaExams.in");
return 0;
}
void main()
{
print();
}
Answer: B
Correct answer: AllIndiaExams.in
The program prints the string once and stops. Applying const to a function's return type simply qualifies the value returned; for a return type of int it has no practical effect at all, since the returned value is a copy that the caller here discards.
Nothing in the code causes repetition - print() is called once from main and returns 0. The trap is reading int const print() as something exotic; it is an ordinary function with a redundant qualifier.
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