How to write a code for random pick from 1-1000 numbers?
The output should contain the 10 numbers from the range
1-1000 which should pick randomly, ie ,for each time we run
the code we should get different outputs.
Answer Posted / kameshwar
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main()
{
int i;
srand(time(NULL));
printf("\n Ten random numbers between 1 and 1000 are \n");
for(i=0;i<10;i++)
printf("%d ",(rand() % 1000) + 1);
return EXIT_SUCCESS;
}
| Is This Answer Correct ? | 5 Yes | 0 No |
Post New Answer View All Answers
How can you tell whether a program was compiled using c versus c++?
How can a program be made to print the name of a source file where an error occurs?
When is a null pointer used?
Why can’t constant values be used to define an array’s initial size?
Can we assign integer value to char in c?
Why clrscr is used after variable declaration?
In which language linux is written?
What is structure in c language?
What is the use of header files?
What is non linear data structure in c?
Why c is called free form language?
What is the g value paradox?
Write a program to print all permutations of a given string.
What is omp_num_threads?
Is there a built-in function in C that can be used for sorting data?