please someone could test this program with c and tell me what the error is in this program, the way i see it is that it excutes the if and the else at the same time. I won't be long here's the program ....
One last note i tried the getch() function of course with the conio.c but it didn't make much diffrence so try it too, it might work with youCode:#include<stdio.h> main() { float guess, incr; char ch; printf("Think of a number between 1 and 99, and\n"); printf("I'll guess what it is. type 'e'' for equal , 'g' for greater and 'l' for less than\n"); incr = guess = 50; while (incr > 1.0) { printf("\nIs your number greater than or less than %.0f?\n",guess); scanf("%c",&ch); incr = incr / 2; if (ch == 'g' ) guess = guess + incr; else guess = guess - incr; } printf("\n The number is %.0f. Am I not clever? \n",guess); }



LinkBack URL
About LinkBacks



