Skip to content

Instantly share code, notes, and snippets.

@thunderInfy
Created March 17, 2020 11:31
Show Gist options
  • Select an option

  • Save thunderInfy/f201a81056059f65aa9175209702083f to your computer and use it in GitHub Desktop.

Select an option

Save thunderInfy/f201a81056059f65aa9175209702083f to your computer and use it in GitHub Desktop.
#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