C Codes
Beginners
C on Unix
Code Snippets
Data Structures
File Operations
Games Graphics
Gnu-Linux
Hardware
Mathematics
Miscellaneous
Small Programs
Sorting
C > Miscellaneous sample source codes
Tossing coins, rand()
Tossing coins, rand() #include <stdio.h> #include <time.h> #include <stdlib.h> 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; }
Privacy Policy
|
Link to Us
|
Links