main()

{

unsigned char i=0;

for(;i>=0;i++) ;

printf("%d\n",i);

}



main() { unsigned char i=0; for(;i>=0;i++) ; ..

Answer / susie

Answer :

infinite loop

Explanation

The difference between the previous question and this
one is that the char is declared to be unsigned. So the i++
can never yield negative value and i>=0 never becomes false
so that it can come out of the for loop.

Is This Answer Correct ?    7 Yes 0 No

Post New Answer

More C Code Interview Questions

main() { int i; printf("%d",scanf("%d",&i)); // value 10 is given as input here }

2 Answers   IBM,


write a origram swaoing valu without 3rd variable

2 Answers  


Write a routine to draw a circle (x ** 2 + y ** 2 = r ** 2) without making use of any floating point computations at all.

2 Answers   Mentor Graphics, Microsoft,


How will u find whether a linked list has a loop or not?

8 Answers   Microsoft,


main() { int y; scanf("%d",&y); // input given is 2000 if( (y%4==0 && y%100 != 0) || y%100 == 0 ) printf("%d is a leap year"); else printf("%d is not a leap year"); }

1 Answers  






void main() { static int i; while(i<=10) (i>2)?i++:i--; printf(ā€œ%dā€, i); }

2 Answers  


main(int argc, char **argv) { printf("enter the character"); getchar(); sum(argv[1],argv[2]); } sum(num1,num2) int num1,num2; { return num1+num2; }

1 Answers  


main() { int i=5,j=6,z; printf("%d",i+++j); }

2 Answers  


main() { char c=' ',x,convert(z); getc(c); if((c>='a') && (c<='z')) x=convert(c); printf("%c",x); } convert(z) { return z-32; }

1 Answers  


write a program to find out roots of quadratic equation "x=-b+-(b^2-4ac0^-1/2/2a"

2 Answers  


main() { int i = 100; clrscr(); printf("%d", sizeof(sizeof(i))); } a. 2 b. 100 c. 4 d. none of the above

5 Answers   HCL,


char inputString[100] = {0}; To get string input from the keyboard which one of the following is better? 1) gets(inputString) 2) fgets(inputString, sizeof(inputString), fp)

1 Answers  


Categories