Hello friends, here I am posting a program "To guess the number....."
#include<stdio.h>#include<time.h>#include<stdlib.h>int main(void){int theNumber;int tries,guess,yesno=1;srand (time(0)); do { theNumber=rand()% 1000+1; tries=0; printf("I have a number between 1 and 1000.""Can you guess my number? \n\n"); do { printf("Please type your first guess:"); scanf("%d",&guess); ++tries; if (guess > theNumber) printf("To high!! Try again.\n\n"); if (guess < theNumber) printf("To low!! Try again. \n\n"); }while (guess != theNumber);printf("Excellent! You guessed the number!\n");
printf("Would you like to play again?\n");printf("Please type (1=yes, 2=no)?\n");scanf("%d",&yesno); } while(yesno==1); return 0;}
Comments
Post a Comment