Yeni başlayanlar için C oyun programı kodları 1 (C game program codes for beginners)




Bu çok basit bir tahmin oyunudur.Girdiğiniz sayılarla belirlenen sayıyı tahmin etmeye çalışırsınız.Çıktıları dilinize çevirebilirsiniz.
This is a very simple guessing game. You try to guess the number determined by the numbers you enter.You can translate the printouts into your language.




#include <stdio.h>
#include<stdlib.h>
#include<time.h>
void main()
{
int num=0,guess=0;
int times=0;
srand(time(NULL));
num=rand()%100+1;
scanf("%d", &guess);
while(guess!=num)
{
if(guess<num)
{
printf("WRONG.Think a larger number");
scanf("%d", &guess);
times++;
}
if(guess>num)
{
printf("WRONG.Think a smaller number");
scanf("%d", &guess);
times++;
}
if(guess==num)
{
printf("Congratulations",times+1);
}
}
printf(" Congratulations %d num %d You have already known.", num, times+1);
 
}


Yorumlar