Hi friends! So here it is,Our simple Guessing game coded in C language.Copy and paste it then run it and enjoy the game wink emoticonVideo tutorial Link
P.S. - Don't forget to ask doubts in comments.. smile emoticon
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
int score=10,guess=101,num;
randomize();
num=random(100);
#include<conio.h>
#include<stdlib.h>
void main()
{
int score=10,guess=101,num;
randomize();
num=random(100);
printf("\nA random no. between 1 and 100 is choosen..guess the
no.- ");
while(1)
{
scanf("%d",&guess);
clrscr();
if(num>guess)
printf("The no. is greater than %d, guess again- ",guess);
if(num<guess)
printf("The no. is smaller than %d, guess again- ",guess);
if(num==guess)
break;
score--;
}
printf("Correct! Your score is %d. Press any key...",score);
getch();
clrscr();
printf("\nFor more cool coding,\n\t\t\tReach our fb page @https://www.facebook.com/coolcoding.org");
getch();
while(1)
{
scanf("%d",&guess);
clrscr();
if(num>guess)
printf("The no. is greater than %d, guess again- ",guess);
if(num<guess)
printf("The no. is smaller than %d, guess again- ",guess);
if(num==guess)
break;
score--;
}
printf("Correct! Your score is %d. Press any key...",score);
getch();
clrscr();
printf("\nFor more cool coding,\n\t\t\tReach our fb page @https://www.facebook.com/coolcoding.org");
getch();
}
No comments:
Post a Comment