All pastes #883191 Raw Edit

Miscellany

public text v1 · immutable
#883191 ·published 2008-01-30 05:11 UTC
rendered paste body
#include<stdio.h>
void main(){

 char input;
 int counter =0 ;
 int lowerValue=1, higherValue=100;
 int numberOfGuess = 0,myGuess=0 ;
 int count=0;

 myGuess = (lowerValue + higherValue)/2;
 printf("Is your number greater or equals to%d\n",myGuess);
 
 scanf("%c", input);


 while(count!=1){
 myGuess = (lowerValue+higherValue)/2;
 if(input == '>'){
     higherValue = myGuess;
     printf("Is your number greater or equals to%d\n",myGuess);
          numberOfGuess++;
     }else if(input == '<'){
     lowerValue = myGuess;

     printf("Is your number greater or equals to%d\n",myGuess);
 numberOfGuess++;
         }else{
              count=1;
         printf("You have guessed the number in%d\n",numberOfGuess);
                 }

 }

 }