edited by
8,722 views

5 Answers

Best answer
17 votes
17 votes
include<stdio.h>
main()
{ int i;                    // variable declared with name i 
 for(i=0;i<5;i++)           // loop condition satisfied
 {
   int i=10; //new memory created with variable i and assign 10 to it with scope inside Forloop
   printf("%d" , i);         // print value of i which is declared inside for loop. 
   i++;                      //inner declare i which contain 10 is incremented.
 }
return 0;
}

Note for every time loop condition check with outer declare i and dor every outer declared i every time new variable i  is declared and assign 10 to it .

so output will be 10, 10, 10, 10, 10,

Atlast vlaue of outer i = 5 and inner i = 11

selected by
1 votes
1 votes
Think the answer is OPTION D compilation error.

There are 2 errors in the given program:

1. The header file included is wrong (it must be stdio.h ) which raises reference error.

2. The variable 'in' is undeclared in the program and since C language doesn't support variables without declaration, it raises and error.
Answer:

Related questions

15 votes
15 votes
1 answer
1
8 votes
8 votes
4 answers
2
sh!va asked May 7, 2017
5,499 views
What is the output of the following program?#include<stdio.h int tmp=20; main() { printf("%d", tmp); func(); printf("%d", tmp); } func() { static int tmp=10; printf("%d",...
0 votes
0 votes
1 answer
3
TusharKumar asked Dec 22, 2022
523 views
can anyone explain how the for loop works here..?
3 votes
3 votes
2 answers
4