Can someone help me with a c code Develop a two dimensional


Can someone help me with a c++ code
Develop a two dimensional array of, at least, ten rows and ten columns and fill it using the random number generator. Print out the contents of the array in a matching number of rows and columns. Sort the array for smallest to largest. Print out the contents of the array in a matching number of rows and columns. Add all of the elements of the array and output the total and the average along with appropriate information to the user.

Solution

#include<iostream.h>
#include<conio.h>
#include <stdio.h>
#include <stdlib.h>

void main()
{
int a[10][10];
int i,j;
float average;
int sum=0;
for(i=0;i<10;i++)
{
for(j=0;j<10;j++)
{
a[i][j] = rand()%100+1;
}
}
cout<<\"Elements of array are\"<<endl;
for(i=0;i<10;i++)
{
for(j=0;j<10;j++)
{
cout<<a[i][j];
}
}
cout<<endl;
cout<<\"Elements of array after sorting\"<<endl;
for(int row = 0; row < 10; row++)
{
for(int i=0;i<10;i++)
{
for(int j=i;j<10;j++)
{
if(MyArray[row][i]<MyArray[row][j]) //the condition was flipped in the program you gave me, notice that would have sorted them ascendingly
{
int temp= a[row][i];
a[row][i]=a[row][j];
a[row][j]=temp;
}
}
}
}

for(i=0;i<10;i++)
{
for(j=0;j<10;j++)
{
cout<<a[i][j];
sum = sum+a[i][j];
}
}
cout<<endl;
average = sum/10;
cout<<\"Sum of elements of array is\"<<sum<<endl;
cout<<\"Average of elements of array is\"<<average<<endl;
}

 Can someone help me with a c++ code Develop a two dimensional array of, at least, ten rows and ten columns and fill it using the random number generator. Print
 Can someone help me with a c++ code Develop a two dimensional array of, at least, ten rows and ten columns and fill it using the random number generator. Print

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site