In C programming
Propose an algorithm to generate random numbers and store each value as an entry in an array.
Algorithm:
==========
int arr[50];
srand(time(0));
for(int i = 0; i<50; i++)
arr[i]=rand()%10;
for(int i=0;i<50;i++)
display arr[i]
end of algorithm
===================
#include <stdio.h>
#include<time.h>
#include<stdlib.h>
int main()
{
int arr[50];
srand(time(0));
for(int i = 0; i<50; i++)
arr[i]=rand()%10;
for(int i=0;i<50;i++)
printf("%d ",arr[i]);
return 0;
}
DON'T FORGET TO HIT LIKE.
THANKS BY HEART.
COMMENT DOWN IF ANY PROBLEM.
Get Answers For Free
Most questions answered within 1 hours.