view raw
Dave Lockwood Dave Lockwood - 6 months ago 33
C Question

What would be the output and why?

I was asked in an interview that what would be the Output of the following program::

int main(){
int i=1;

I ran it in my pc and got no answer.So I wanna know what happened inside the for loop?


for loops are top-tested, which means the condition (i>=2) is tested before the loop is entered the first time. i is 1, so the condition (i>=2) isn't true, so the loop isn't entered, so nothing is printed.