please help me solve this...

hi all master...can help me with calculation for average in array? im blank..doing search but not helping me..sorry...all week script is same? i want get average for each week..tq

program use:
Dev-C++ 5.0 beta 9.2 (4.9.9.2) with Mingw/GCC 3.4.2

PURPOSE
To solve programming problems using two-dimensional arrays.

REQUIREMENT / ASSIGNMENT QUESTION
Write a program to read Air Pollution Index (API) as an input from the user and store the data in a two-dimensional array. Your program should calculate the average API for each of the four weeks. Example of API readings are given in the table below.
Mon Tue Wed Thus Fri Sat Sun Average
Week 1 88 43 56 78 98 102 105 ??
Week 2 101 110 115 130 78 77 56 ??
Week 3 44 67 89 45 33 45 33 ??
Week 4 100 189 201 55 34 67 88 ??


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185


#include <stdio.h>
#include <conio.h>
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;

int main()

{
int array[4][7] = {                         //declare array 4x7
    {1,2,3,4,5,6,7},
    {8,9,10,11,12,13,14},
    {15,16,17,18,19,20,21},
    {22,23,24,25,26,27,28},
    

    
};
int sum = 0;
  

//set all day to 0
for(int y = 0; y < 7; y++){                 //loop for days
        for(int x=0; x<4; x++){         //loop for week
                array[x][y]=0;
                }
                }
    

    printf("Air Pollution Index (API)\n");
    printf("\n\t : The value in 4 x 7 Array table : \n");
    printf("Week 1, please key in your data from Monday - Sunday \n");
    
    {
              cout<<"Week 1 \n";
              
              
              cout<<"Monday \n";
              cin>>array[1][1];
              
              cout<<"Tuesday \n";
              cin>>array[1][2];
              
              cout<<"Wednesday \n";
              cin>>array[1][3];
              
              cout<<"Thursday \n";
              cin>>array[1][4];
              
              cout<<"Friday \n";
              cin>>array[1][5];
              
              cout<<"Saturday \n";
              cin>>array[1][6];
              
              cout<<"Sunday \n";
              cin>>array[1][7];
              
              sum=array[1][1]+[1][2]+[1][3]+[1][4]+[1][5]+[1][6]+[1][7]/7);
              
              cout<<"Average for Week 1 is" sum;
    }




    printf("Week 2, please key in your data from Monday - Sunday \n");


    {
              cout<<"Week 2 \n";
              
              
              cout<<"Monday \n";
              cin>>array[2][1];
              
              cout<<"Tuesday \n";
              cin>>array[2][2];
              
              cout<<"Wednesday \n";
              cin>>array[2][3];
              
              cout<<"Thursday \n";
              cin>>array[2][4];
              
              cout<<"Friday \n";
              cin>>array[2][5];
              
              cout<<"Saturday \n";
              cin>>array[2][6];
              
              cout<<"Sunday \n";
              cin>>array[2][7];
              
              sum=array[2][1]+[2][2]+[2][3]+[2][4]+[2][5]+[2][6]+[2][7]/7);
              
              cout<<"Average for Week 2 is" sum;
    }



    printf("Week 3, please key in your data from Monday - Sunday \n");
    
      {
              cout<<"Week 3 \n";
              
              
              cout<<"Monday \n";
              cin>>array[3][1];
              
              cout<<"Tuesday \n";
              cin>>array[3][2];
              
              cout<<"Wednesday \n";
              cin>>array[3][3];
              
              cout<<"Thursday \n";
              cin>>array[3][4];
              
              cout<<"Friday \n";
              cin>>array[3][5];
              
              cout<<"Saturday \n";
              cin>>array[3][6];
              
              cout<<"Sunday \n";
              cin>>array[3][7];
              
              sum=array[3][1]+[3][2]+[3][3]+[3][4]+[3][5]+[3][6]+[3][7]/7);
              
              cout<<"Average for Week 3 is" sum;
    }
  
    
    
    
    printf("Week 4, please key in your data from Monday - Sunday \n");
    
    
    {
              cout<<"Week 4 \n";
              
              
              cout<<"Monday \n";
              cin>>array[4][1];
              
              cout<<"Tuesday \n";
              cin>>array[4][2];
              
              cout<<"Wednesday \n";
              cin>>array[4][3];
              
              cout<<"Thursday \n";
              cin>>array[4][4];
              
              cout<<"Friday \n";
              cin>>array[4][5];
              
              cout<<"Saturday \n";
              cin>>array[4][6];
              
              cout<<"Sunday \n";
              cin>>array[4][7];
              
              sum=array[4][1]+[4][2]+[4][3]+[4][4]+[4][5]+[4][6]+[4][7]/7);
              
              cout<<"Average for Week 4 is" sum;
    }
    
    
    
    
        cout("Air Pollution Index (API) table:\r\n");
        cout("Week   1   2   3   4   5   6   7       average");
        cout("        ---------------------------------------);
        
        
system(¡§PAUSE ¡¨);
getch();
return 0; //add in the last line 
} 
 





sample that i want similar like this:
http://www.java2s.com/Code/CSharp/Collections-Data-Structure/Usesatwodimensionalarraytostoregradesforstudents.htm

http://www.java2s.com/Code/Cpp/Data-Structure/Defineandinitiateatwodimensionalarray.htm
Last edited on
error compile log

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Compiler: Default compiler
Executing  g++.exe...
g++.exe "C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp" -o "C:\Users\PuteraDanPuteri\Documents\Untitled5.exe"    -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include"  -I"C:\Dev-Cpp\include\c++\3.4.2\backward"  -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32"  -I"C:\Dev-Cpp\include\c++\3.4.2"  -I"C:\Dev-Cpp\include"   -L"C:\Dev-Cpp\lib" 
C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp: In function `int main()':
C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp:61: error: expected primary-expression before '[' token
C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp:61: error: expected primary-expression before '[' token
C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp:61: error: expected primary-expression before '[' token
C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp:61: error: expected primary-expression before '[' token
C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp:61: error: expected primary-expression before '[' token
C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp:61: error: expected primary-expression before '[' token
C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp:61: error: expected `;' before ')' token

C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp:63: error: expected `;' before "sum"
C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp:97: error: expected primary-expression before '[' token
C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp:97: error: expected primary-expression before '[' token
C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp:97: error: expected primary-expression before '[' token
C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp:97: error: expected primary-expression before '[' token
C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp:97: error: expected primary-expression before '[' token
C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp:97: error: expected primary-expression before '[' token
C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp:97: error: expected `;' before ')' token
C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp:99: error: expected `;' before "sum"

C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp:131: error: expected primary-expression before '[' token
C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp:131: error: expected primary-expression before '[' token
C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp:131: error: expected primary-expression before '[' token
C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp:131: error: expected primary-expression before '[' token
C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp:131: error: expected primary-expression before '[' token
C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp:131: error: expected primary-expression before '[' token
C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp:131: error: expected `;' before ')' token
C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp:133: error: expected `;' before "sum"

C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp:167: error: expected primary-expression before '[' token
C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp:167: error: expected primary-expression before '[' token
C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp:167: error: expected primary-expression before '[' token
C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp:167: error: expected primary-expression before '[' token
C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp:167: error: expected primary-expression before '[' token
C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp:167: error: expected primary-expression before '[' token
C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp:167: error: expected `;' before ')' token
C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp:169: error: expected `;' before "sum"
C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp:175: error: no match for call to `(std::ostream) (const char[35])'
C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp:176: error: no match for call to `(std::ostream) (const char[47])'

C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp:177: error: missing terminating " character
C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp:180: error: stray '\161' in program
C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp:180: error: stray '\167' in program
C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp:180: error: stray '\161' in program

C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp:180: error: stray '\168' in program
C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp:180: error: `PAUSE' undeclared (first use this function)
C:\Users\PuteraDanPuteri\Documents\Untitled5.cpp:180: error: (Each undeclared identifier is reported only once for each function it appears in.)

Execution terminated
Last edited on
Topic archived. No new replies allowed.