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 / navdeep singh
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
int main(void)
{
int i;
randomize();
printf("Ten random numbers from 0 to 1000\n\n");
for(i=0; i<10; i++)
printf("%d\n", rand() % 100);
return 0;
}
| Is This Answer Correct ? | 15 Yes | 7 No |
Post New Answer View All Answers
Explain how can I pad a string to a known length?
What is external variable in c?
Why ca not I do something like this?
What are the different data types in C?
What happens if a header file is included twice?
When the macros gets expanded?
Why do some versions of toupper act strangely if given an upper-case letter?
find the sum of two matrices and WAP for it.
What is const and volatile in c?
the process of defining something in terms of itself is called (or) in C it is possible for the functions to call themselves. A function called a) nested function b) void function c) recursive function d) indifinite function
In a switch statement, what will happen if a break statement is omitted?
How can you pass an array to a function by value?
What is static and volatile in c?
How to compare array with pointer in c?
What is a structure in c language. how to initialise a structure in c?