I need help with the Random number generator. I would like to get 0 or 1 and so I am using the code pasted below but I would somehow like to control the number of 1's or 0's I get, eg., I would like to get 30% of the values as 1 but randomly positioned.

Please help. Thanks.

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <math.h>

int main(){
int i;
int value;

for (i=0; i<20; i++){//print out 20 different random numbers
value = (rand()%2);//value is either 0 or 1
printf("%d \n", value);
return 0;