Guess a magic number game in c
#include<stdio.h> //header file stdio.h
#include<conio.h> //header file conio.h
#include<stdlib.h> //header file stdlib.h
main()
{
int guess,magic; //variable declaration
magic=rand(); //using random generator function
printf("enter you guess number");
scanf("%d",&guess); //assign value to guess
if(guess==magic) //checking conditions
printf("right you won");
else{
printf("wrong you lose");
printf("the right answer is %d",magic);
}
getch();
} //end of the program
#include<stdio.h> //header file stdio.h
#include<conio.h> //header file conio.h
#include<stdlib.h> //header file stdlib.h
main()
{
int guess,magic; //variable declaration
magic=rand(); //using random generator function
printf("enter you guess number");
scanf("%d",&guess); //assign value to guess
if(guess==magic) //checking conditions
printf("right you won");
else{
printf("wrong you lose");
printf("the right answer is %d",magic);
}
getch();
} //end of the program
No comments:
Post a Comment