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


Please Help Members By Posting Answers For Below Questions

What is the best way to store flag values in a program?

580


When should we use pointers in a c program?

633


What are the primitive data types in c?

579


What is this infamous null pointer, anyway?

611


write a program in c language to print your bio-data on the screen by using functions.

6251






What is data types?

641


Explain what is the difference between a free-standing and a hosted environment?

635


How do you define CONSTANT in C?

653


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

678


Can you write the algorithm for Queue?

1555


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.

1497


How many header files are in c?

553


Why is not a pointer null after calling free?

598


in programming languages a statement or part of a statement that specifies several different execution sequences a) constructs b) distructs c) executes d) none

604


Write a program to swap two numbers without using a temporary variable?

611