Tuesday, 5 August 2014

A simple program for tossing a coin and getting a random output in C

#include<time.h>
#include<stdio.h>
main()
{
time_t start,end;
//predefined function in c
//after the user defined function does its work
start=clock();//Timer starts
char coin[5];
int t;
//start=clock();
scanf("%s",coin);
end=clock();//Timer stops

t=(end-start)/CLOCKS_PER_SEC;
if(t%2==0){printf("\nYou won\nFirst Move Will Be Yours");}
else{printf("\nYou loose\nFirst Move Will Be By CPU");}


}

No comments:

Post a Comment