[Updated] Goldman Sachs Aptitude Test Questions and Answers
Practice List of TCS Digital Coding Questions !!!
Take 50+ FREE!! Online Data Interpretation Mock test to crack any Exams.

C Programming :: Basic Concepts - Discussion

Home > C Programming > Basic Concepts > MCQs Questions Discussion

2 / 90

What is the output of the following C Program?

#include<stdio.h>
void main(){
    int i;
    for(i=0;i<5;i++){
         int x=0;
         printf("%d",x);
         x++;
    }  
}

A1234

B1234

C0

DInfinite loop

ECompilation error

Answer: Option (Login/Signup)

Show Explanation

Each time when the control enters the loop, x becomes equal to 0, and everytime 0 gets printed. Eventhough, in line 7 the value of x gets incremented by 1, but that's of no use because each time when the control enters the loop, value of x gets re-initializied to 0.

Therefore, the correct output will be 00000

Asked In ::

Post Your Answer Here:     

Reply    
Rate This: +0 -0
    Report


Report Error

Please Login First Click Here