C Project – How to Generate Random Number
Get Certified in C Programming and Take Your Skills to the Next Level
Program 1
#include<stdio.h>
#include<conio.h>
#include<time.h>
#define clrscr() system("cls")
int main()
{
clrscr();
int n,l,u;
// srand(time(NULL));
printf("Enter value of Lower Bound: ");
scanf("%d",&l);
printf("Enter value of Upper Bound: ");
scanf("%d",&u);
n=(rand()%(u+l+1))+l;
printf("%5d",n);
// int n;
// int myrandom[100];
//
// // n=rand();
// //n=rand()%100;
// //n=rand()%10;
// for(int i=0;i<10;i++)
// {
// n=rand()%100;
// myrandom[i]=n;
// i++;
// }
// for(int i=0;i<10;i++)
// {
// printf("%5d",myrandom[i]);
// }
return 0;
}
Did you like this article? If Yes, please give DataFlair 5 Stars on Google

