Create a program that will generate 50 random numbers between 1 and 10000, displ
ID: 653981 • Letter: C
Question
Create a program that will generate 50 random numbers between 1 and 10000, display them in groups of 10 across, sort them, and again display them in groups of 10 across.
SAMPLE OUTPUT:
UNSORTED:
42 8469 6335 6503 9171 5726 1480 9361 6965 4467
5706 8148 3284 6829 9962 492 2996 1944 4828 5437
2395 4606 3903 154 293 2384 7423 8718 9720 9897
5448 1729 4773 1540 1870 9914 5670 6302 7037 9895
8706 3814 1326 337 7675 4665 5143 7712 8256 6869
SORTED:
42 154 293 337 492 1326 1480 1540 1729 1870
1944 2384 2395 2996 3284 3814 3903 4467 4606 4665
4773 4828 5143 5437 5448 5670 5706 5726 6302 6335
6503 6829 6869 6965 7037 7423 7675 7712 8148 8256
8469 8706 8718 9171 9361 9720 9895 9897 9914 9962
Explanation / Answer
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void sort(int a,int b);
void main()
{
int n,max,num[10000],i,j,k;
printf("Enter any random number");
scanf("%d",&n);
printf("Enter the maximum value");
scanf("%d",&max);
printf("Range of random number from 0 to %d are ",n,max);
randomsize();
for(k=1;k<=n;k++)
{
num[i]=random(max);
printf("%d",num[i]);
}
getch();
}
void sort(int a,int b)
{
int j,num[10000],n;
for(b=0;b<n;b++)
{
for(j=b+1;j<n;j++)
{
if(num[b]>num[j])
{
a=num[b];
num[b]=num[j];
num[j]=a;
printf("Number sorted are ",num[b]);
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.