where is the Mistake ??

#include <iostream>
using namespace std;


void main ()

{

int x, i;

int avg, sum=0;

int Array [] = {34,45,56,38,42,51,53};

x= sizeof(Array)/4;


for (i=0; i<x; i++)

{
sum = sum + Array [i];


}



avg= sum / x;

cout <<"The Addition of the numbers:\n"<<sum<<x<<endl;

cout <<"\nNums of Pre-Enterd value:\n" <<x\n << endl;


cout << "The Avarage of the calculated nums is:\n" << avg << endl;


system ("pause");





}

\

Maybe you should remove outputing x in the line

cout <<"The Addition of the numbers:\n"<<sum<<x<<endl;

Also here

cout <<"\nNums of Pre-Enterd value:\n" <<x\n << endl;

you shall remove \n after x
Last edited on
And remove the \n from the second cout line like this:

cout << "\nNums of Pre-Enterd value:\n" << x << endl;

It works for me without it.
I believe that main is supposed to be an int function. Try fixing that.
Topic archived. No new replies allowed.