Thursday, 2 January 2014

Guess A Number

A number that tells Guesses A number.


#include <stdio.h>
#include <stdlib.h>
int main()
{
int num=0,num1=100,tries=0,z;
char ch;
printf("I have a number(between 1 to 100)can you guess it ");

    while(tries<=5)
    {z=(num+num1)/2;

        printf("\nif number is greater then %d enter (y)yes/(n)no or if it is the number enter e\n\nEnter your choice: ",z);
        scanf("%c",&ch);


if(ch=='y'||ch=='Y')
       {
           num=z;
       }
       else if (ch=='n'||ch=='N')
       {
           num1=z;
       }
       else if (ch=='e'||ch=='E')
       {
          printf("\n%d Excellent you thought",z);
    }
    }



    return 0;
}

No comments:

Post a Comment