Discussion
What will be the output of the following program?
#include <stdio.h>
static int y = 1;
int main()
{
static int z;
printf("%d %d", y, z);
return 0;
}
Answer: C
Correct answer: 1 0
y is a file-scope static int explicitly initialised to 1. z is a static local with no initialiser, and every object with static storage duration is zero-initialised - unlike an auto variable, which would hold junk. So the output is 1 0.
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