C program to generate random number in a range.

Written by siddhartha. Posted in Misc

Source Code

/*************************************************************************************/
/*  C program to generate random number in a range.*/
/*  Download more programs at http://sourcecode4u.com/ */
/*************************************************************************************/
#include <stdlib.h>
#include <stdio.h>
#include <time.h> 
main()
{
int x,start,end;
srand((unsigned)time(NULL));
printf("Enter the range start and end :::");
scanf("%d %d",&start,&end);
for(x=0;x<=100;x++) //generates 100 random numbers :)
printf("%i\t",rand()%end + 1);

}

Out Put

BLOG COMMENTS POWERED BY DISQUS