This is the code I'm trying to compile
I don't have any online storage so I'll just put it all on here.
//---------------------------------------------------
/*
* function.cpp
*
*this program demonstrates functions with arguments
*
*/
#include Carbon/Carbon.h
#include iostream.h
#include stdio.h
//square - returns a square of its argument
// doublevar - the value to be squared
// returns the square of doublevar
double square(double doublevar)
{
retutrn doublevar * doublevar;
}
//sumSequence - add a sequence of numbers entered from
// the keyboard and squareduntil the
// user enters a negative number.
// return - the summation of the square
// of the numbers entered
int sumSequence(void)
{
//loop forever
int accumulator = 0;
for (;
{
//fetch another number
double doubleValue = 0;
cout << "Enter next number: ";
cin >> doubleValue;
// if it's negative...
if (doubleValue < 0)
{
//...then exit from the loop
break;
}
//.. otherwise calculate the square
int value = (int)square(doubleValue);
//now add the square to the
//accumulator
accumulator= accumulator+ value;
}
}
int main(int arg, char* pszArgs[])
{
cout<<"This porgram sums miltiple series \n"
<<"of numbers. Terminate each sequence \n"
<<"by entering a negative number. \n"
<<"Terminate the series by entering two \n"
<<"negative numbers in a row. \n"
//continue to accumulate numbers...
int accumulateddoubleValue;
do
{
//sum a sequence of numbers entered from
//the keyboard
cout <<"\nEnter next sequence\n";
accumulateddoubleValue = sumSequence();
//now output the accumulated result
cout <<"\nThe total is: "
<<accumulateddoubleValue
<<"\n";
//...until the sum returned is 0
}while (accumulateddoubleValue != 0);
cout <<"Program terminated\n";
return 0;
}
//---------------------------------------------
I can't see anything wrong with it. Also cc gives me errors when i try to use it. GCC isn't in my /usr/bin folder and I definatley can't compile from PB when writing c++ (I did new project C++ file). How do I compile from PB? I'll tinker around a bit and see what I can do.
Thanx for the help.