- Code:
#include <iostream.h>
#include <stdio.h>
int main()
{
int amount;
int number;
int This[21] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int total;
cout << "Please enter the amount of numbers you wish to average (20 max): ";
cin >> amount;
for(number=0; number = amount; ++number)
{
cout << "\nNumber: ";
scanf(" %d", This);
}
total = /*edited to fix forum length
it just said this[0]+[1] and the whole array*/
cout << "\nAverage is: " << total;
return 0;
}
I know this is pretty confusing, but here is what I am trying to do.
This program is supposed to average the amount of numbers you want. By the looks of it, I probably did it the hard way, and the wrong way. My program pauses after I enter the amount of numbers. Any ideas?
By the way, I put scanf because it wouldn't let me use cin...