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


Please Help Members By Posting Answers For Below Questions

count = 0; for (i = 1;i < = 10; i++);count = count + i; Value of count after execution of the above statements will be a) 0 b) 11 c) 55 d) array

679


What is the difference between the local variable and global variable in c?

532


Are there namespaces in c?

570


What does stand for?

598


Why do we use & in c?

593






What are the differences between Structures and Arrays?

610


Why functions are used in c?

587


what does static variable mean?

657


What is structure pointer in c?

573


Explain what standard functions are available to manipulate strings?

613


Is it possible to have a function as a parameter in another function?

599


How do we open a binary file in Read/Write mode in C?

680


#include show(int t,va_list ptr1) { int a,x,i; a=va_arg(ptr1,int) printf(" %d",a) } display(char) { int x; listptr; va_star(otr,s); n=va_arg(ptr,int); show(x,ptr); } main() { display("hello",4,12,13,14,44); }

772


Explain modulus operator. What are the restrictions of a modulus operator?

600


Is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?

655