C > Miscellaneous
Tossing coins, rand()
Tossing coins, rand() #include
#include
#include
int main(void) { int coin = 0; int guess = 0; srand(time(NULL)); coin = rand() % 2; printf("Your call ... 0 = head, 1 = tail: "); scanf("%d", &guess); if(coin == guess) printf("You called it correctly ... !\n"); else printf("No way ... !\n"); return 0; }
C Codes
Beginners
C on Unix
Code Snippets
Data Structures
File Operations
Games Graphics
Gnu-Linux
Hardware
Mathematics
Miscellaneous
Small Programs
Sorting