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 print ASCII code for a given digit.

0 Answers   EXL, HCL,


1. Duplicate the even numbers. -1 Sample I/O Array1:- 4,2,24,3,22 Updated Array:- 4,4,2,2,24,24,3,22,22 2. Reverse the array in a region - 1 Sample I/O Array1:- 4,2,24,3,22,41,21 Enter Region:- 2,5 Update Array:-4,41,22,3,24,2,21 3. Store first the even digits in an array and then odd digits in same array -2 Sample I/O Array1:- 4,2,24,3,22,41,21 Array 2:- 4,2,2,4,2,2,4,2,3,1,1 4. Store the count of the digits in all numbers in an array and print the count. -2 Sample I/O Array1:- 4,2,9,3,7,41,28 Array 2:- 0,1,1,1,2,0,0,1,1,1 1-1;2-1;3-1;4-2;7-1;8-1;9-1 5. Store all palindrome numbers in to another array -2 Sample I/O Array1:- 4,22,9,313,7,141,28 Array 2:- 4,22,9,313,141 6. Arrange the array in such a way that odd numbers come first and then even numbers -1 Sample I/O Array1:- 4,22,9,313,7,141,28 Update Array1:- 9,313,7,141,4,22,28 7. Store into another array by inserting it in the right place - 2 Sample I/O Array1:- 4,22,9,313,7,141,28 Array2:- 4 /4,22 /4,9,22 /4,9,22 ,313 /4,7,9,22 ,313 /4,7,9,22 ,141,313 / 4,7,9,22,28 ,141,313 8. Merge two sorted arrays in a sorted fashion - 3 Sample I/O Array 1:- 3,6,7,9,11,16 Array 2:- 1,2,5,7,20 Array 3:- 1,2,3,5,6,7,9,11,16,20 9. Upadte the array so that an array element is followed by its revere - 1 Sample I/O Array 1:- 13,63,74,9,11,16 Updated Array 1:- 13,31,63,36,74,47,9,9,11,11,16,16 10.Spread the digits of the array in the same array. -1 Sample I/O Array 1:- 13,63,74,9,11,16 Updated Array 1:-1,3,6,3,74,9,1,1,1,6 11.Shift the boundary of array to have only 2 digit numbers. Sample I/O Array 1:- 139,643,74,9,101,126 Updated Array 1:- 13,96,43,74,91,11,26 12.Print the largest occuring digit in an array of N numbers. Sample I/O Array 1:- 13,63,74,9,11,16 1 occurs most.

2 Answers   Intel,


Is the following code legal? struct a { int x; struct a b; }

4 Answers  


Is c weakly typed?

0 Answers  


what is the difference between getch() and getchar()?

10 Answers   Huawei, Infosys,






What is floating point exception error? And what are different types of errors occur during compile time and run time? why they occur?

1 Answers  


Explain how can I open a file so that other programs can update it at the same time?

0 Answers  


Find if a number is power of two or not?

1 Answers  


Is double link list a linear data structure? If Yes, Why?If No, Why?

4 Answers  


What is string length in c?

0 Answers  


Why does not use getgh(); and <conio.h> in c language.

3 Answers   Elofic,


i need all types of question paper releted to "c" and other language.

0 Answers  


Categories