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
What is the best way to store flag values in a program?
When should we use pointers in a c program?
What are the primitive data types in c?
What is this infamous null pointer, anyway?
write a program in c language to print your bio-data on the screen by using functions.
What is data types?
Explain what is the difference between a free-standing and a hosted environment?
How do you define CONSTANT in C?
what are the advanced features of functions a) function declaration and prototypes b) calling functions by value or by reference c) recursion d) all the above
Can you write the algorithm for Queue?
design and implement a data structure and performs the following operation with the help of file (included 1000 student marks in 5 sub. and %also) 1.how many students are fail in all 5 subjects (if >35) 2. delete all student data those are fail in all 5 subjects. 3. update the grace marks (5 no. if exam paper is 100 marks) 4. arrange the student data in ascending order basis of marks. 5.insert double of deleted students with marks in the list.
How many header files are in c?
Why is not a pointer null after calling free?
in programming languages a statement or part of a statement that specifies several different execution sequences a) constructs b) distructs c) executes d) none
Write a program to swap two numbers without using a temporary variable?