for(i=1;i>0;i++);
printf("i=%d",i);
what will be the answer????

Answers were Sorted based on User's Feedback



for(i=1;i>0;i++); printf("i=%d",i); what will be the answer????..

Answer / rajesh jat

i is a signed integer
it will print only and only -32768
//KEEP IT DIRTY

Is This Answer Correct ?    16 Yes 3 No

for(i=1;i>0;i++); printf("i=%d",i); what will be the answer????..

Answer / vignesh1988i

since after the loop there is a semicolon , so according to
the compiler this semicolon will be taken as next line and
the loop will be iterating till the termination condition....


output possibilities :

1)if the variable 'i' which is used as an signed integer
variable , this will take an infinite values and stop at one
instance and it will terminate the application. but wont
display anything in the screen

2) if this is an unsigned variable this will be infinite
with values going on and on without stopping.. but not
displaying it...


conclusion : loop is infinite here.....



thank u

Is This Answer Correct ?    12 Yes 8 No

for(i=1;i>0;i++); printf("i=%d",i); what will be the answer????..

Answer / ankit shekhavat

after for lop,there is a semicolon.it means loop terminate
here..condition inside the loop will always true.so it will
be an infinite loop..nothing will be printed on the screen.
for next statement there will be printed any garbage value...

Is This Answer Correct ?    7 Yes 6 No

for(i=1;i>0;i++); printf("i=%d",i); what will be the answer????..

Answer / guest

The value of i starts at 1 and increments from there. The
loop terminates when i <= 0.

For an unsigned value, this is only possible when i == 0.

For a signed value, incrementing a positive value by 1 will
eventually overflow within the binary word to become the
most negative value an integer can hold. The sequence is
thus (..., INT_MAX-1, INT_MAX, INT_MIN) and the loop
terminates, where INT_MAX and INT_MIN are the "most
positive" and "most negative" values for the word size used
on your machine.

Is This Answer Correct ?    1 Yes 1 No

for(i=1;i>0;i++); printf("i=%d",i); what will be the answer????..

Answer / guest

i=1i=1etc.

Is This Answer Correct ?    1 Yes 7 No

for(i=1;i>0;i++); printf("i=%d",i); what will be the answer????..

Answer / naren

ans is i=2

Is This Answer Correct ?    1 Yes 13 No

for(i=1;i>0;i++); printf("i=%d",i); what will be the answer????..

Answer / guest

4

Is This Answer Correct ?    0 Yes 18 No

Post New Answer

More C Interview Questions

Write a program to implement a round robin scheduler and calculate the average waiting time.Arrival time, burst time, time quantum, and no. of processes should be the inputs.

0 Answers   Aspiring Minds,


logic for generating all the combinations of the any number of given letters. ex::::::::: if a,b,c,d are given the o/p should be abcd,dcba,dbac,bcad,................ 4*3*2*1 combinations............

2 Answers   Infosys,


Do you know what are the properties of union in c?

0 Answers  


What are the c keywords?

0 Answers  


What will happen when freeing memory twice

2 Answers  






i=10,j=20 j=i,j?(i,j)?i:j:j print i,j

1 Answers   CSC,


how to convert binary to decimal and decimal to binary in C lanaguage

7 Answers   BPO, Far East Promotions, IBM, RBS,


What are the keywords in c?

0 Answers  


What is selection sort in c?

0 Answers  


write a program to print data of 5 five students with structures?

0 Answers  


what is difference between userlevel threads and kernel level threads ?what are the trades offs between these two approaches ? what approach is most frequently used and why ?

1 Answers  


c program to arrange digits in a no in ascending and descending order

1 Answers  


Categories