Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program which: 1. Assigns data given below into the 2D array of integers

ID: 3760086 • Letter: W

Question

Write a program which: 1. Assigns data given below into the 2D array of integers which is 10x10 2. Prints out the contents of the 2D array after assigning the data to make sure correct data was assigned. 3. Figures out and prints out the square root of the sum of ALL the elements in the 2D array. 4. Figures out and prints out the average of ALL THE ELEMENTS in the 2D array. 5. Figures out and prints out the square root of the sum of the values of the elements of EACH ROW in the 2D array. 6. Figures out and prints the average of EACH COLUMN in the 2D array. 7. Figures out and prints out the square root of the sum of the values on the diagonal from upper left hand corner to bottom right hand corner. 8. Figures out and prints out the average of the values on the diagonal from upper right hand corner to bottom left hand corner. To make assigning the 100 values easy we will test with the following data:

Explanation / Answer

#include<stdio.h>
#include<conio.h>
#include<math.h> /* For Square root function */

int main()

{

int a[10][10],sum=0,su=0,s=0, total=0, i,j;

float avg,ar,ag;

printf("Enter Values ");

for(i=0;i<10;i++) /* To read values runtime */

{

for(j=0;j<10;j++)

{

scanf("%d",&a[i][j]);

}

}

printf("The values entered in a 2D array are ");

for(i =0 ; i<10 ; i++)

{

for(j=0;j<10;j++)

{

printf("%d ",a[i][j]); /* Print Vaues in 2D array

total = total + a[i][j]; /* For finding total sum of elements in array */

}

printf(" ");

}
       /* Finding square root of sum of all elements*/

printf("The Square Root of sum of all elements in 2D array is %.2f ", sqrt(total));

avg = (float)total/100;
printf("The average is %.2f ",avg);

for(i=0;i<10;i++)
{
for(j=0;j<10;j++)
{
sum = sum+a[i][j];
}
printf("The square root of sum of elements of %d th row is %.2f ",i+1,sqrt(sum));
sum=0;
}
for(i=0;i<10;i++)
{
for(j=0;j<10;j++)
{
s = s+a[j][i];
}
ar = (float)s/100;
printf("Average of column %d is %.2f ",i+1,ar);
sum=0;
}
for(i=0;i<10;i++)
{
for(j=0;j<10;j++)
{
if(i==j)
su = su+a[i][j];
}
}
printf("The square root of diagonals is %.2f ",sqrt(su));
ag=(float) su/10;
printf("The average of diagonals is %.2f ",ag);
getch();
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote