Tuesday, July 28, 2009

C++ Help!!!?

Hi, I had to write an array that took the average of 10 numbers entered by the user and I did that with this program:





#include %26lt;iostream%26gt;


using namespace std;





int main()


{


int num[10];


int sum = 0;


float average;





for (int x = 0 ; x %26lt; 10 ; x++)


{


cout %26lt;%26lt; "Enter a number: ";


cin %26gt;%26gt; num[x];


sum = sum + num[x];


}





average = float(sum) / 10;





cout%26lt;%26lt;"The average is: "%26lt;%26lt;average%26lt;%26lt;endl;





}





but now I have to make it display all of the entered numbers that are higher than the average... How in the world do I do that??

C++ Help!!!?
// add this code at the end





cout %26lt;%26lt; "the numbers which are greater than average, are: ";


for (int x=0; x%26lt;10; x++)


{


if (num[x] %26gt; average)


{


cout %26lt;%26lt; num[x];


}


}

tarot cards

No comments:

Post a Comment