Newb Array

I'm in an online "intro" to programming class, and for my assignments my prof. gives us the psuedocode and then expects us to convert it to c++ statements. He doesn't give as any tips and is very hard to get in touch with. For this assignment we are supposed to create a program that allows the user to enter 15 numbers, then displays each number and it's difference from the numeric average of the numbers entered. I have errors in lines 63 and 68, there may be more you can spot however... In line 63 i must be declared and I have no idea htf I should do that. And in 68 I am missing a primary expression before else, and a ";" before it. Here is my code so far, any pointers are greatly appreciated;
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
// Start
//     Declarations
//         num SIZE = 15
//         num numbers[SIZE]
//         num counter = 0
//         num total = 0
//         num average = 0
//         num diffFromAvg = 0
//         num  SENTINEL = -1
//
//     output "Please enter a positive number: "
//     input numbers[counter]
//     while ((counter < 15) AND (numbers[counter] <> SENTINEL))
//       counter = counter + 1
//       total = total + numbers[counter]
//       output "Please enter a positive number: "
//       input numbers[counter]
//     endwhile
//     if (counter > 0) then
//       average = total/counter
//       for i = 0 to counter - 1
//         diffFromAvg = numbers[i] - average
//         output "Number[",i,"]: ",numbers[i]," Difference from Average is ",diffFromAvg
//       endfor
//     else
//       output "Processing incomplete. No values in the array."
//     endif
// Stop

#include <iostream>
#include <cstdlib>

using namespace std;

int main()
{
    int SIZE=15;
    int numbers[SIZE];
    int counter=0;
    double total=0;
    double average=0;
    double diffFromAvg=0;
    int SENTINEL=-1;
    
    cout<<"Please enter a positive number: "<<endl;
    cin>>numbers[counter];
         while((counter<15)&&(numbers[counter]!=SENTINEL))
              {
              counter=counter+1;
              total=total+numbers[counter];
              cout<<"Please enter a positive integer: "<<endl;
              cin>>numbers[counter];
              }
         if(counter>0)
              {
              average=total/counter;
              }
         for(i==0; counter-1;)
              {
              diffFromAvg=numbers[i]-average;
              cout<<"Number[",i,"]: "<<numbers[i]<<"Difference from Average is "<<diffFromAvg<<endl;
              }
         else
             {
             cout<<"Processing incomplete. No values in the array."<<endl;
             }
    system("PAUSE");
    return 0;
}


Also, if you think I should change the structure, let me know. I have a hard time teaching myself things v.v
try the following
1) Replace line no. 58 with :-
for(int i==0; counter-1;)

2)replace line number 61 with
cout<<"Number["<<i<<"]: "<<numbers[i]<<"Difference from Average is "<<diffFromAvg<<endl;


enjoy programming :)
Topic archived. No new replies allowed.