Created
March 17, 2020 11:31
-
-
Save thunderInfy/f201a81056059f65aa9175209702083f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <sys/types.h> | |
| #include <unistd.h> | |
| int main(){ | |
| srand(getpid()); | |
| int N = 10; | |
| int i = 0; | |
| int sum = 0; | |
| int randombit; | |
| while(i<N){ | |
| randombit = rand()%2; | |
| sum += randombit; | |
| } | |
| printf("Sum of %d random bits is %d\n",N,sum); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment