update l4.c

This commit is contained in:
Stepan 2026-05-07 19:07:58 +03:00
parent e3dbc13e9a
commit 69107ea260
2 changed files with 12 additions and 2 deletions

14
c/l4.c
View file

@ -1,17 +1,27 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main() { int main() {
int x = 7; srand(time(NULL));
int x = rand() % 11;
int s = 0; int s = 0;
while(1) { while(1) {
int pol; int pol;
printf("Number "); printf("Number ");
scanf("%d", &pol); scanf("%d", &pol);
if(pol == 7) { if(pol == x) {
printf("the number is guessed\n"); printf("the number is guessed\n");
break; break;
} }
else { else {
printf("the number is not guessed\n"); printf("the number is not guessed\n");
if(pol > x) {
printf("less\n");
}
else {
printf("more\n");
}
s++; s++;
if(s == 3) { if(s == 3) {
printf("Game over\n"); printf("Game over\n");

0
c/l5.c Normal file
View file