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 do you print only part of a string?
What are runtime error?
What is #include called?
Is r written in c?
write a program that will open the file, count the number of occurences of each word in the the complete works of shakespeare. You will then tabulate this information in another file.
Discuss the function of conditional operator, size of operator and comma operator with examples.
How macro execution is faster than function ?
Given an array of 1s and 0s arrange the 1s together and 0s together in a single scan of the array. Optimize the boundary conditions?
Explain what is wrong with this statement? Myname = ?robin?;
What is zero based addressing?
Explain what standard functions are available to manipulate strings?
What is the -> in c?
What do you mean by Recursion Function?
Array is an lvalue or not?
What will be your course of action for a push operation?