Computer Science, asked by shlokdm, 27 days ago

What will this program print?
main
{
int i = 2;
{
int i = 4, j = 5;
printf("%d %d", i, j);
}
printf("%d %d", i, j);
}
a. 4525
b. 2525
c. 4545
d. None of the these​

Answers

Answered by arth696
9

Answer:

A. 4525

Hope it helps :) ... ....

Answered by vinod04jangid
0

Answer:

d. None of these

Explanation:

In the given program, in the 3rd line, i is initialized to 2. In the 5th line i and j are declared and i is initialized to 3 whereas j is initialized to 5. In the next line, i and j is printed which will give the output 4 5. In the 8th line, again i and j is printed, but here i will be printed as 2 but j is not declared.

As we know, a variable is alive only in the particular block in which it has been declared. Here j was declared not in the particular block. So j cannot be accessed outside it.

Hence, this program throws an error saying j is undeclared in line 8.

#SPJ3

To know about C program and how it works, visit:

https://brainly.in/question/294885

To know the output of the program, #include int main() { int a[2][3] = {1, 2, 3, 4, 5}; int i = 0, j = 0; for (i = 0; i < 2; i++) for (j = 0; j < 3; j++) printf("%d ", a[i][j]); return 0; }, visit:

https://brainly.in/question/634779?msp_srt_exp=4

Similar questions