Discussion
Predict the output of below code:
#include "stdio.h"
#include "stdlib.h"
int main(int argc, char *argv[]) {
char temp[20];
gcvt(23.45,2, temp);
printf("%s", temp);
return 0;
}
Answer: D
Correct answer: Output : 23
gcvt(value, ndigit, buf) converts a double to a string with ndigit significant digits - not decimal places. With ndigit = 2, 23.45 rounds to two significant figures, giving 23, which is what is printed.
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