Rasgele üretilen sayıyı deneme yanılma yoluyla bulan program | Kaçıncı defada bulduğunu yaz

09:57 0 Comments

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include "time.h"


void main() {

// rasgele üretilen sayıyı deneme yanılma yoluyla bulan program | Kaçıncı defada bulduğunu yaz


int sayi, a;
int sayac = 1;
srand(time(NULL));
a = rand() % 100 + 1;

printf("Lutfen bir sayı giriniz : ");
scanf_s("%d", &sayi);

while (sayi != a){


printf("Lutfen bir sayı giriniz : ");
scanf_s("%d", &sayi);
printf("DENEME-%d \n ", sayac);
printf("uretilen sayi= %d ", a);


if (sayi > a) {
printf(" Asagiya in abicim\n ");

}
if (sayi < a) {
printf(" Yukariya cik abicim\n ");

}
if (sayi == a) {
printf(" TEBRIKLER DOGRU CEVAP ");
break;

}

sayac++;


}



_getch();

}

erdem

Some say he’s half man half fish, others say he’s more of a seventy/thirty split. Either way he’s a fishy bastard. Google

0 yorum: