#include<stdio.h>
#include<stdlib.h>
void main()
{
int i,N;
N=20;
printf("Random data points are: \n");
for(i=0;i<N;i++)
{
printf("%d \n", rand() %100);
}
getch();
}
suppose random data points are : 6 8 9 17 19 5 4 1 14 10 9 .upto 20..
how can i select 'k' numbers from this output generated by Rand function. for example: if i take user input k=4 then the program must return 4 values from this output..
please guide me..thank u
use scanf("%d",&N);
printf("Random data points are: \n");
scanf("%d",&N);
for(i=0;i<N;i++)
{
printf("%d \n", rand() %100);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.