Hi,
I wrote this code to add 10 numbers and find their average. It will not out put average.
What am I doing wrong?

Thanks for the help.

#include <iostream>

using namespace std ;
int main ( )
{
	double Sum;

	double Average;

	double Numbers[10];

	int K;

	Sum = 0;

	Average = 0;

	for ( K = 0; K < 10; K++ )

	{
		cout <<  " Enter Your Numbers " << ( K + 1 ) << endl;
		cin >> Numbers[K];
		Sum = Sum + Numbers[K];
	}
	    Average = Sum/10;
		for ( K = 0; K < 10; K++);

		{
			cout << " The numbers you Entered  are " << Numbers [K] << endl;
		}
		  cout << " The Average of the Numbers is " << Average << endl;
		  return(0);
}

Edited 5 Years Ago by Narue: Added code tags

At Line 20 , where it says
cout << "The Numbers you Entered are" << Number [K] i feel something wrong there?

Hey jashbela,
There is nothing wrong wrong in the average logic. I have compiled it also. The average result is right.

Please refrain from using "leet speak" e.g "ty" and "wit"

Keep it Clear
Do post in full-sentence English
Do not write in all uppercase or use "leet", "txt" or "chatroom" speak

#include <iostream>
   
       
   
      using namespace std ;
   
      int main ( )
  
      {
  
     

 
       double Sum = 0;
  
       
  
       double  Average = 0,Numbers;
  

  for(Numbers=0;Numbers<=10;Numbers++)
  {
      cout << " Enter Your Numbers ";
  
      cin >> Numbers;
  
      Sum = Sum + Numbers;
  
   
  
      Average = Sum/10;
  }
      cout << " The numbers you Entered are " << Numbers<< endl;
  
      cout << " The Average of the Numbers is " << Average << endl;
 
  
      return(0);
  
      }

// just take a look of mt simple program/// nice day

Edited 5 Years Ago by Nick Evan: Added CODE tags

Hi,
I wrote this code to add 10 numbers and find their average. It will not out put average.
What am I doing wrong?

Thanks for the help.

for ( K = 0; K < 10; K++);

		{
			cout << " The numbers you Entered  are " << Numbers [K] << endl;
		}

Mistake at that point in line 21

No Need To Use
<<( K + 1 ) << endl;
When You Getting The Number

Edited 5 Years Ago by Nick Evan: removed plug

I think your code will be from line 18 to 24.

for ( K = 0; K < 10; K++ )
cout << " Enter Your Numbers "  ;
for ( K = 0; K < 10; K++ )
{
cin >> Numbers[K];
Sum = Sum + Numbers[K];
}
This article has been dead for over six months. Start a new discussion instead.