hamburger

What will be the output of the following C code?#include main( ){int i;for (i=0; i<5; i++){int i = 10;printf("%d", i);i++;}return 0;}

By BYJU'S Exam Prep

Updated on: October 17th, 2023

  1. 10 11 12 13 14
  2. 10 10 10 10 10
  3. 0 1 2 3 4
  4. Compilation error

The output of the following C code #include main( ){int i;for (i=0; i<5; i++){int i = 10;printf(“%d”, i);i++;}return 0;} is 10 10 10 10 10.

#include

main( )

{

int i;

for ( i=0; i<5; i++ ) //this loop runs 5 times

{

int i = 10;// initialised to 10

printf(“%d”, i); // It prints 10

i++;// incremented by 1 but here i is a local variable inside a for loop.[this i values are 0,1,2,3,4]

}

return 0;

}

Output will be 10 10 10 10 10

Summary:-

What will be the output of the following C code?#include main( ){int i;for (i=0; i<5; i++){int i = 10;printf(\%d, i);i++;}return 0;} 10 11 12 13 14, 10 10 10 10 10, 0 1 2 3 4, Compilation error

The output of #include main( ){int i;for (i=0; i<5; i++){int i = 10;printf(\%d, i);i++;}return 0;} is 10 10 10 10 10

Related Questions:-

Our Apps Playstore
POPULAR EXAMS
SSC and Bank
Other Exams
GradeStack Learning Pvt. Ltd.Windsor IT Park, Tower - A, 2nd Floor, Sector 125, Noida, Uttar Pradesh 201303 help@byjusexamprep.com
Home Practice Test Series Premium