Contact Learn C
Copy

Program 200:Guess the Toss of a Coin

Program 200:
 
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
 main ()
 {
 int number,guess;
 srand ( time(NULL) );
 //To get numbers between 0 and 1
 number = rand() % 2;
 printf("Guess 1 for tail or 0 for head\n");
 scanf("%d",&guess);
 printf("Result of toss is\n");
 if(number==0)
 {
  printf("Head\n");
 }
 else
 {
  printf("Tail\n");
 }
 printf("You guessed\n");
 if(guess==0)
 {
  printf("Head\n");
 }
 else
 {
  printf("Tail\n");
 }
 if(number==guess)
 {
      printf("Hurray! You won the toss\n");
 }
 else
 {
  printf("Oops! Better Luck Next Time\n");
 }
 }

Explanation:

//Coming Soon...

Output:

Guess the Toss of a Coin









 

3 comments:

  1. Flipping a coin in the air, catching it, then determining whether it has come up heads or tails is a common way to decide who starts off a two-person game or resolve a binary question. Because you expect that heads is as likely to come up as tails, it sounds like a fair way to make a choice.

    ReplyDelete
  2. coins are the most cheap of every single Ancient coin. Other old .nft games

    ReplyDelete
  3. The simplest ones will clearly be the country that you dwell in. The most straightforward method for starting is by gathering coins that have previously being given and are still available for use. NFT Calendar

    ReplyDelete

Donate

Download App and Learn when ever you want

Get it on PlayStore
Get it on Amazon App Store
Get it on Aptoide