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

When should a type cast not be used?

0 Answers  


Explain what is meant by 'bit masking'?

0 Answers  


Q.11 Generate the following pattern using code in any language(c/c++/java) for n no. of rows 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1

2 Answers  


write a program to find the given number is prime or not

2 Answers   Accenture, Vasutech,


What is the package for freshers(Non IIT) in amazon(hyderabad). And what is the same for those who are a contract employee.

0 Answers  






SIR PLS TELL ME THE CODE IN C LANGUAGE TO PRINT THE FOLLOWING SERIES 1 1 2 1 1 2 3 2 1 1 2 3 4 3 2 1 1 2 3 2 1 1 2 1 1

4 Answers  


Why is c so popular?

0 Answers  


What are the main characteristics of c language describe the structure of ac program?

0 Answers  


Snake Game: This is normal snake game which you can find in most of the mobiles. You can develop it in Java, C/C++, C# or what ever language you know.

7 Answers   Accenture, Gridco, IBM, Kevin IT, TCS, Vimukti Technologies,


typedef struct { int i:8; char c:9; float f:20; }st_temp; int getdata(st_temp *stptr) { stptr->i = 99; return stptr->i; } main() { st_temp local; int i; local.c = 'v'; local.i = 9; local.f = 23.65; printf(" %d %c %f",local.i,local.c,local.f); i = getdata(&local); printf("\n %d",i); getch(); } why there there is an error during compiling the above program?

1 Answers  


What is the condition that is applied with ?: Operator?

0 Answers  


what is constant pointer?

3 Answers  


Categories