Discussion
What will be the output of the following program?
#include <stdio.h>
int main()
{
register int i = 2;
static char ch = 'A';
auto float j;
int k;
k = ++ch && i;
k = ++ch;
j = i-- + ++k * 2;
printf("%d %f", k, j);
return 0;
}
Answer: C
Correct answer: 68 138.000000
Follow the four statements, with ch starting at 'A' = 65.
k = ++ch && i;-chbecomes 66; both operands are non-zero, sokis 1.k = ++ch;-chbecomes 67 andktakes that value.j = i-- + ++k * 2;-i--contributes 2 (leavingiat 1);++kmakesk68, and \(68 \times 2 = 136\); so \(j = 2 + 136 = 138\).
Printed with %d and %f: 68 138.000000.
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