CODE FOR TOSS GAME
#include<stdio.h>
#include<time.h>
#include<stdlib.h> // its a standard library header file
main()
{
int number,guess;
srand(time(NULL)); // this is the function to generate a random number between 0 and 1..
number=rand()%2; // this is the actual operation for 1 and 0..
// if no. is even it gives 0 and 1 otherwise..
printf("\n \t ENTER 1 FOR TAIL AND 0 FOR HEAD : ");
scanf("%d",&guess);
printf(" \n THE RESULT OF THE TOSS IS : ");
// testing the condition for head or tail...
if(number==0)
printf(" head \n !!!");
else
printf("tail \n");
printf(" You guessed ");
if(guess==0)
printf("Head\n");
else
printf("Tail \n");
if(number ==guess)
printf(" hurray ! you won the toss !!!");
else
printf(" bad luck !!\n Better luck next time : : ");
}
video link : https://youtu.be/ildwXmZTvTA
Comments
Post a Comment