// Needed to Initialize variable PROCEED, so while statment begins //
cout << " Hi I will take 10 numbers you enter and provide you with an average.";
cout << " Do you want to START ? (y/n) " ;
cin >> proceed;
cout << endl;
while ( proceed != 'n')
{
cout << " Enter a Number ";
cin >> numbers [k];
}
if (k =0; k <10; k =k++ )
{
sum = sum + numbers[k]<< endl << + (k + 1);
}
average = sum/10;
// calculates the average //
{
cout << " Number amount " << (k+1) << " is " << numbers[k];
// Prints out the numbers entered //
}
cout << " Tha average is " << average;
// Prints out the average //
#include"stdafx.h"
#include <iostream>
usingnamespace std;
// Arrays & Functions Declaration //
float numbers[10];
// This Array will read in the numbers //
float sum=0;
// This will take in the total amount //
float average;
// Computes the average of total numbers //
int k=0;
// Takes in the users input
void readMoreNumbers (char &goOn);
// Checks to see if more numbers are to be entered //
// ******************************************************************** //
int main (int argc, char * const argv[])
{
// variable Definitions //
char proceed; // Quits? coded y/n //
// Needed to Initialize variable PROCEED, so while statment begins //
cout << " Hi I will take 10 numbers you enter and provide you with an average.";
cout << " Do you want to START ? (y/n) " ;
cin >> proceed;
cout << endl;
while ( proceed != 'n')
{
cout << " Enter a Number ";
cin >> numbers [k++];
if(k>=10) break;//end of while loop
}
for(k =0; k <10; k =k++ )//for instead of if
{
sum = sum + numbers[k];//<< endl << + (k + 1);//
}
average = sum/10;
// calculates the average //
{
cout << " Number amount " << (k) << " is " << numbers[k];
// Prints out the numbers entered //
}
cout << " Tha average is " << average;
// Prints out the average //
system("pause");
return 0;
}
i try running.it is ok.
good luck
1 2 3 4 5 6 7 8 9 10 11 12 13
Hi I will take 10 numbers you enter and provide you with an average.Do you want to START ? (y/n)y
Enter a Number 5
Enter a Number 6
Enter a Number 7
Enter a Number 8
Enter a Number 9
Enter a Number 0
Enter a Number 3
Enter a Number 4
Enter a Number 1
Enter a Number 2
Number amount 10 is 45 Tha average is 4.5.Press any key to continue.....