Jul 21, 2011 at 11:56pm UTC
ok this program is meant to calculate an average from a list of "user defined values " inputed untill the user inputs 0; its saposto use and call fucntions, global and local functions heres my code whats wrong with it besides making me cross eyed.
i keep getting this warnig
K:\10rl.cpp In function `double sum(double, double)':
17 K:\10rl.cpp no post-increment operator for type
#include<cmath>
#include <stdio.h>
#include <stdarg.h>
using namespace std;
//sum function//
double sum(double num,
sum = 00.00;
num;double sum)
{
int h = 0;
sum = num+sum;
for(h = 0 ; h<count++ ; sum);
return sum;
}
//average fucntion//
double average(double sum, int count)
{
int i = 0;
double average = 00.00;
average = sum/count;
for(i = 0; i<count++ ; average);
return average;
}
int main()
{
cout<<endl;
double num;
double sum = 00.00;
double average;
double count =0;
cout << "Enter values you want averaged: "<<endl;
while (num != 0)
{
for (int x = 1; x < count; x++)
cout << "#"<<x++<< " = ";
cin >> num;
cin.get();
}
if (num == 0)
{
cin>>sum;
cout<<sum<<endl;
cin.get();
}
else if (sum > 0);
{
cin>>average;
cout<<average<<endl;
cin.get();
}
cin.get();
return EXIT_SUCCESS;
}
Jul 25, 2011 at 7:21am UTC
There should be more errors than that..
double sum(double num, sum = 00.00; num;double sum)
is not how you write a function..
for (h = 0 ; h<count++ ; sum);
does nothing. Moreover, count has not been declared anywhere.
There seem to be other problems, but I'll stop here for now. Try it yourself. Any when you post code, use [cod e][/co de] tags.