Question

Write a program that reads in a table of numbers and finds out the average of...

Write a program that reads in a table of numbers and finds out the average of each row and column. This program should first take two numbers as number of rows and columns as input from the user.

Homework Answers

Answer #1

#include<iostream>
using namespace std;
int main()
{
   int a[20][20],n,m,i,j,sum_row,sum_column;
   cout<<"enter number of rows";
   cin>>m;
   cout<<"enter no of columns";
   cin>>n;
   cout<<"enter row and column values";
   for(int i=0;i<m;i++)
   {
   for(int j=0;j<n;j++)
   cin>>a[i][j];
   }
   cout<<"entered table is\n";
   for(int i=0;i<m;i++)
   {
   for(int j=0;j<n;j++)
   {
   cout<<a[i][j]<<" ";
   }
   cout<<"\n";
   }
  
   for(int i=0;i<m;i++)
   {  
       sum_row = 0;
       for(int j=0;j<n;j++)
       {
       sum_row = sum_row+a[i][j];
       }
   cout<<"\nAverage of row "<<i+1<<" is "<<sum_row/n<<"\n";  
   }
  
  
   for(int j=0;j<n;j++)
   {  
       sum_column = 0;
       for(int i=0;i<m;i++)
       {
       sum_column = sum_column+a[i][j];
       }
   cout<<"\nAverage of column "<<j+1<<" is "<<sum_column/m<<"\n";  
   }
  
   return 0;
  
}

The Output is:

Hope this helps. If you like the answer please upvote. If you have any queries or suggestions regarding the answers please leave them in the comments section so I can update and improve the answer. Thank you.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
In Java. Write a program that reads-in a times table-number. The program, using this table-number will...
In Java. Write a program that reads-in a times table-number. The program, using this table-number will produce the following report (as shown). The first item in the report is a number with starting value 1. Second column is the word “ X ” (representing the times symbol). Third column is the table-number (itself). Following is an equal sign “ = “ (representing a result). Last column is the result of the operation for that line or row which is the...
In C++ write a program for a multiplication table It must Prompt the user for two...
In C++ write a program for a multiplication table It must Prompt the user for two integers between 1 and 20 (inclusive) • also must Calculates and displays the multiplication table in a well-formatted output The table must include a label for each row and column The program must follow the requirements: • Validates user input, displaying an error message and prompting to user to enter another integer if the input is invalid, and repeating it as many times as...
C++ INSTRUCTIONS Problem Specification : Write a program that reads a group of numbers from the...
C++ INSTRUCTIONS Problem Specification : Write a program that reads a group of numbers from the user and places them in an array of type float. Once the numbers are stored in the array, the program should average and print the result. Use pointer notation wherever possible. Program Output (with Input Shown in Bold): Enter number: 2 Enter another (y/n)? y Enter number: 4 Enter another (y/n)? y Enter number: 6 Enter another (y/n)? y Enter number: 8 Enter another...
(Write in C++) Write a program that reads in two numbers and, if the input is...
(Write in C++) Write a program that reads in two numbers and, if the input is valid, outputs 2 times the product of the integers that lie between the two values (including the values themselves). If either number is not an integer, or if the first number is not less than the second number, just output an error message. The sample runs below should give the idea. User inputs are in bold. Important Notes: Your program should use a loop...
Step 1: Write a Java program that finds the sum of 10 numbers entered by the...
Step 1: Write a Java program that finds the sum of 10 numbers entered by the user. Step 2: Modify the previous program so that it asks the user how many numbers they have, inputs that many numbers, and finally outputs the average of their numbers. The messages to the user should be clear throughout.
Write a C++ program that reads two integers from the user. The program should tell whether...
Write a C++ program that reads two integers from the user. The program should tell whether the two numbers are equal or not.
Write a python program to find the sum of the first n natural numbers, where the...
Write a python program to find the sum of the first n natural numbers, where the value of n is provided by the user. What is the sum of the first 200 numbers? Write a program that finds the average of a series of numbers entered by the user. As in the previous problem, the program will first ask the user how many numbers there are. Note: the average should always be a float. What is the average of 10.2,...
Use C++ Write a program that first reads in how many whole numbers the user wants...
Use C++ Write a program that first reads in how many whole numbers the user wants to sum, then reads in that many whole numbers, and finally outputs the sum of all the numbers greater than zero, the sum of all the numbers less than zero (which will be a negative number or zero), and the sum of all the numbers, whether positive, negative, or zero. The user enters the numbers just once each and the user can enter them...
Java Program : Please save the program with the name ‘Dstring.java’ Write a program that reads...
Java Program : Please save the program with the name ‘Dstring.java’ Write a program that reads a string from the keyboard. If the length of the string is an even number, your program should split the string into two strings of equal length. If the length of the string is odd, your program should split the string into two strings where the first part has one more character than the second part. Your program should output the two strings it...
Vowels and consonants Write a program that reads a word and prints the number of vowels...
Vowels and consonants Write a program that reads a word and prints the number of vowels and consonants in the word. For this exercise assume that ‘a’, ‘e’, ‘i’, ‘o’, ‘u’, and ‘y’ are vowels. For example, if the user enters the input “Harry”, the program should print “The word contains 2 vowels and 3 consonants”.
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT