-
Notifications
You must be signed in to change notification settings - Fork 1
/
guess.c
68 lines (52 loc) · 1.86 KB
/
guess.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(){
int n,sayac,tahmin,user_score=0,comp_score=0;
char secim;
// Get input from user.
printf("Sayı tahmin oyununu oynamak istiyor musunuz ? (E/H)");
scanf("%c",&secim);
// Check input is 'H' or 'h'
if(secim=='H' || secim == 'h')
printf("O zaman programı meşgul etme");
while(secim=='E' || secim == 'e'){
// Create random number.
srand(time(NULL));
n=rand()%100+1;
// Get prediction from user.
printf("\n1 ve 100 arasında sayı tahmin ediniz : ");
scanf("%d",&tahmin);
for(int i=1;;i++){
if(tahmin<n){
printf("\nDaha buyuk bir sayiyla tekrar tahmin ediniz : %d Hakkınız kaldı",10-i);
scanf("%d",&tahmin);
if(i==9){
printf("\n\nHakkınız doldu. :(");
comp_score = comp_score + 1;
printf("Skor : %d - %d ", user_score, comp_score);
break;
}
}
else if(tahmin>n){
printf("\nDaha kucuk bir sayiyla tekrar tahmin ediniz : %d Hakkınız kaldı",10-i);
scanf("%d",&tahmin);
if(i==9){
printf("\n\nHakkınız doldu. :(");
comp_score = comp_score + 1;
printf("Skor : %d - %d ", user_score, comp_score);
break;
}
}
else if(tahmin==n){
printf("\nTebrikler %d. Tahmininiz Dogru !!! ",i);
user_score = user_score + 1;
printf("Skor : %d - %d ", user_score, comp_score);
break;
}
}
printf("\n\nTekrar oynamak ister misin ? (E/H)");
scanf(" %c",&secim);
}
printf("%c", secim);
}