Where could i find the answers for the exercies in c++ primer

Yes folks,

I'm new to the forum and c++. I've decided to start learning c++ so I'm well prepared when i enter into a foundation degree course on September. I've chosen c++ primer 5th edition as the book to guide me there (it was between that and Programming: Principles and Practice Using C++). I'm going to do all the exercises in the book being only on exercise 1.4 I've already stumbled upon a problem. The question is

"Exercise 1.4: Our program used the addition operator, +, to add two
numbers. Write a program that uses the multiplication operator, *, to print
the product instead."

The error that im getting is " expected ; before std " on line 6" the first std.

#include <iostream>

int main()

    std::cout << "enter two numbers" std::endl;

    int v1 = 0, v2 = 0;

    std::cin >> v1 >> v2;

    std::cout << "The multiplication of" << v1 << " and " << v2
              << "is " << v1 * v2 << std::endl;

    return 0;

I'll most likely be stumbling upon lots of problems on lots of different exercises throughout the book rather than torturing yous every 5 minutes it would be handier if i knew where the answers were when i can see no problems within the code.

Thanks in advance for anyones help.


EDIT: Gone it fixed, i was missing the second << on the 6th line. Feel so stupid lol. Although it would be still helpful if i could find the answers somewhere for future reference.
Last edited on
What IDE are you using? It sounds like you might be using some very old C++ version that doesn't have the std namespace.

I don't see anything wrong with that code.

See below.
Last edited on
On line 6, you're missing a << between "enter two numbers" and std::endl
Thanks for the reply's! That did fix the problem.

Is there website with the answers for the 5th edition?
Maybe this http://cppprimer.jesseolmer.com/index.php5?title=1.2.2 but its for the 4th edition.
Naw that links no good for the 5th edition! Doesn't matter now anyways moved on to the programming: principles and practice using c++. This book actually gives you the information before it gives you an exercise for it so if you don't know how to do something you just need to skim over what you read. Thanks for the effort anyhow!
Topic archived. No new replies allowed.