Still Need Advice : (

I've changed it to what you see below. It's still not working..

help
: (
Thanks

#include <iostream>

using namespace 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 =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 //

return 0;
}
[code] Your code goes here [/code]
What is the problem?

1
2
3
4
5
while ( proceed != 'n')
{
cout << " Enter a Number ";
cin >> numbers [k];
}
Infinite loop
Its not compiling..
at the if statement Line, compiler says: Expected ' ) ' before ' ; ' token

so what I'm I doing wrong?

Aside the infinite loop that ne555 pointed out
1
2
3
4
5
6
7
8
if (k =0; k <10; k =k++ )
{
    sum = sum + numbers[k]<< endl << + (k + 1);
}

//should be..

if(k = 0; k < 10; k++) //you don't need to say that k equals itself incremented. 


The increment operator automatically adds 1 to k.
Last edited on
Topic archived. No new replies allowed.