Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

helloooooaaa

Name: Anonymous 2011-10-09 16:11

what am i doing wrong here? or am i doing anything? im trying to get the average of the given 5 numbers.



#include<iostream>
using namespace std;



int main( )
 {
   
 int x, sum, counter, sonuc;
 sum = 0;
 counter = 0;
 

 
 
 cout<<"enter a number"<<endl;
 cin>>x;
 sum = sum + x;
 counter = counter + 1;
 
 if ( counter <= 5)
 
 cout<<"enter another number"<<endl;
 cin>>x;

else
 
 sonuc = sum/counter;
 cout<<"sonuc = ";
 cout<<sonuc<<endl;
 
  system("PAUSE");
 
 
   return 0;
}

Name: Anonymous 2011-10-09 20:57

int sum = 0;
int x, average
int max = 5;

for (int i = 0; i < max; i++){
cout<<"Enter number: "<<endl;
cin>>x;
sum += x;
}

average = sum/max;
cout<<"Average: " + average<<endl;


Something like that. Not sure, haunt worked with cpp for a while.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List