Get a simple one today
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
main()
{
int a,b;
char c;
srand(time(NULL));
a=1+(rand()%1000);
Printf ("I have a number between 1 and 1000 \ n can you guess the number I want? \ n please enter your guess. \ n");
scanf("%d",&b);
while(b!=-1)
{
if(b==a)
{
Printf ("correct answer \ ndo you want to play again (yes or no)?");
scanf("%c",&c);
scanf("%c",&c);
switch(c){
case 'y':
Printf ("I have a number between 1 and 1000 \ n can you guess the number I want? \ n please enter your guess. \ n");
scanf("%d",&b);
break;
case 'n':
break;
}
}
while(b<a)
{
Printf ("too little, try again \ n");
scanf("%d",&b);
}
while(b>a)
{
Printf ("too large, try again \ n");
scanf("%d",&b);
}
}
}
The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support developpaer.