HELP!!

The rainfall figures in mm are available for each day of the past four weeks. Write a function generateReport() that displays the total rainfall for each week and the most wettest day. The function takes as parameter a two-dimensional array named, figures of size 4 x 7, that contains rainfall figures in which each row represent a week and each column represent a day.

For example, if the array contains the following rainfall data:

Days
0 1 2 3 4 5 6
Week 0 3 0 0 7 8 21 0
Week 1 0 1 1 0 0 0 4
Week 2 9 6 7 0 0 0 0
Week 3 0 0 0 0 0 0 1

Then the output of the function should be displayed as follows:



Week Rainfall data Total
1 3 0 0 7 8 21 0 39
2 0 1 1 0 0 0 4 6
3 9 6 7 0 0 0 0 22
4 0 0 0 0 0 0 1 1

The wettest day was day 6 in week 1.


Write a main program to create a 2d array and ask the user to enter rainfall data the call function generateReport to print the report on screen


can anyone solve this please??
Yeah we can do it, why don't you just try it, it's quite easy if you have 10 minutes
Last edited on
#include<iostream>
using namespace std;
void generatereport (int x[][7],int row)
{
int sum,wet=0,wek,maxd;
cout<<"Week Rainfall Total"<<endl;
for (int i=0;i<row;i++)
{
sum=0;
cout<<i+1<<"\t";
for (int j=0;j<7;j++)
{
cout<<x[i][j]<<" ";
sum+=x[i][j];
if (x[i][j]>wet)
{
wet=x[i][j];
wek=i;
maxd=j;
}
}
cout<<" \b\t"<<sum<<endl;
}
cout<<endl<<"The wettest day was day "<<maxd+1<<" in week "<<wek+1<<endl;
}
int main()
{
int x[4][7]={{3,0,0,7,8,21,0},{0,1,1,0,0,0,4},{9,6,7,0,0,0,0},{0,0,0,0,0,0,1}};
generatereport(x,4);
system ("pause");
return 0;
}

i did this but im not sure
how can you not be sure?
Did you not run it?
im trying to run it but it says source file not compiled..
do you have Visual Studio or something like this?

also: why are there values for 8 days?
Week 0 3 0 0 | 7 8 21 0
Week 1 0 1 1 | 0 0 0 4
Week 2 9 6 7 | 0 0 0 0
Week 3 0 0 0 | 0 0 0 1
its' week 0
week 1
week 2
week 3

they are 7 days not 8

and no i do not have visual studio just the dev c++ program
its' week 0
week 1
week 2
week 3

ops

and no i do not have visual studio just the dev c++ program

press F9, that should compile and run the programm
i did it says "g++.exe has stopped working"

what should i do?
get a better idea/compiler. try visual studio express.
get a better idea/compiler

this, i never liked devc++ because it's ugly and doesn't provide much
try QtCreator, it's awesome and even provides a GUI designer
https://www.qt.io/download-open-source/

well, your programm works, just test it online in cpp.sh for the time being:
http://cpp.sh/9xuz
Last edited on
anyone has the program and check it for me please?
click on the last link I posted before:
http://cpp.sh/9xuz
checked it thanks a lot
you're welcome
Topic archived. No new replies allowed.