Hello I am very very new to C++
I am currently reading a book called
"Sams teach yourself C++ in 24 hours"
And now I am stuck on like, the second program you are told to program.
It's called the "calculator program"
Code:#include <iostream> int add(int x, int y) { //add the numbers x and y together and return the sum std::cout << "Running calculator ...\n"; return (x+y); } int main() { /* this program calls an add() function to add two different sets of numbers togethor and display the results. The add() function doesn't do anything unless it is called by a line in the main() function. */ std::cout << "what is 867 + 5309?\n"; std::cout << "the sum is " << add(867, 5309) << "\n\n"; std::cout << "what is 777 + 9311?\n"; std::cout << "the sum is " << add(777, 9311) << "\n\n"; return 0; }
The purpose of the lesson was to teach you about functions and writing comments in your code.
So i write as it has it in the book and try to compile and run it.
But my program, (DEC C++) says there is a syntax error before the ":" on line 6
and i'm just so very confused, I barely understand what the book has to teach me already. And now an unknown error. All very disconcerting.
I really reallly want to learn how to write in C++ but yeah, i'm so lost.



LinkBack URL
About LinkBacks



