A little help for a new guy? Functions problem!
Forgive me for being such a new guy at this and everything, but I cannot seem to get this code to work right. I'll tell you what's wrong before pasting it all down in one big mess.
This is a school assignment ( we are just getting into C++ (FINALLY! =D) and I have only had experience programming in Pascal. This all seems pretty similar to me, but there are still some wierds about all this. This is a function question...
What seems as if it should be working just isn't for me. It's giving me errors when i goto compile it when things look like they should work. Or at least I think so. So don't laugh at me TOO much when you see this coding x_X.
====================================
Code:
//Made By: Chris M 9/12/2002
//This program gathers a list from the user and returns
//a median and an average from them.
#include <iostream.h>
float median(float h, float l); //declares the median function
float mean(float t, int c); //declares averaging function
int main()
{
float x, temp, high, low;
int count, num, quit;
char choose;
quit = 0;
count = 1;
temp = 0;
x = 0;
high = -999999;
low = 9999999;
cout<<"This program will ask the user for a list of numbers, then find the median and/or average."<<endl;
cout<<"How many numbers are you going to put in? > ";
cin>>num;
for (int countdown = 1; countdown <= num; countdown++){
cout<<"Input #"<<count; cout<<" > ";
cin>>x;
if (x < low) //checks to get the highest and lowest nums.
{
low = x;
}
if (x > high)
{
high = x;
}
temp = temp + x; //adds each number put in and stores into one variable.
count = count + 1;
}
count = count - 1;
do{
cout<<"Choose from the following set of options:"<<endl;
cout<<"Get the (m)edian, (a)verage, or (q)uit? > ";
cin>>choose;
if (choose = 'm')
{
cout<<"The median for your set of numbers will be "<<median(high,low);
}
if (choose = 'a')
{
cout<<"The average for your data set will be "<<mean(temp,count);
}
if (choose = 'q')
{
quit = 1;
}
} while (quit = 0); //ends program.
return 0;
}
{
return (h + l)/2;
return t/c;
}
=====================================
[code tags added by ygfperson]
Thanks to anyone willing to take the time to check this mistake up!