Dave Lockwood Dave Lockwood - 1 year ago 59
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?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download