-
Notifications
You must be signed in to change notification settings - Fork 13
/
Sudesh_.c
35 lines (35 loc) · 1 KB
/
Sudesh_.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main ()
{
int num,i,gueeses=0;
srand(time (0)); //Generates the random no which is not repeated to the prev one
num = rand() % 100 + 1; //Generates the random no in the range of 0 to 100
//printf("No. is %d \n",num);
do
{
printf("Guees the NO. in the range of 0 to 100 !!\n");
scanf("%d",&i); //Takes user input NO.
if(i == num) // It will check the no equal or higher or lower
{
printf("You guess Correctly\n");
}
else if(i < num && i > 0)
{
printf("Enter the higher No. please!! \n");
}
else if(i > num && i < 100 )
{
printf("Enter the lower no please!! \n");
}
else
{
printf("Wrong input\n");
}
gueeses++; // It will count the no of gueeses
}
while(i!=num);
printf("U guees in %d attempts",gueeses); // It will printf The of Gueeses
return 0;
}