Seenu have a fruit shop and arranged the some set of fruits in column and row wise. Seenu needs to find the total number of fruits in each rows. Help him to find out.
Answers
Answer:
#include<iostream>
using namespace std;
int main()
{
int m, n, row, col, sum = 0, row_ind = 0, col_ind = 0;
std::cin >> m >> n;
int row_arr[m];
int i, j;
int mat[m][n];
for(i = 0; i < m; i++)
{
for(j = 0; j < n; j++)
std::cin >> mat[i][j];
}
int z = 0;
for(row=0; row<m; row++)
{
sum = 0;
for(col=0; col<n; col++)
{
sum += mat[row][col];
}
std::cout << sum <<"\n";
row_arr[z++] = sum;
}
return 0;
}
Explanation:
Language used : Python Programming
Program :
rows=int(input())
columns=int(input())
l=[]
for i in range(rows):
l.append(sum(list(map(int,input().split(' ')))))
for i in l:
print(i)
Input :
3
3
1 2 3
7 3 1
7 4 1
Output :
6
11
12
Learn more :
1. Write a program to accept Basic salary of an employee. Calculate and display his gross salary based on the following information...
brainly.in/question/18744315
2. Write the program for : Raju has a square-shaped puzzle made up of small square pieces containing numbers on them...
brainly.in/question/16956126