Hello, I just started to study c++ with Sam's Teach Youself c++ book and ran into a problem with an exercise. I'm using code blocks to compile. I should be getting a return of 2, 48, and 14. However when I click build and run it keeps asking me over and over again if I want to build it now even when I click yes. If I click no it returns a bunch of random numbers. Help please.
#include <iostream>
int main()
{
int x = 8;
int y = 6;
std::cout << std::endl;
std::cout << x - y << “ “ << x * y << x + y;
std::cout << std::endl;
return 0;
}
You're using the wrong quotations. Thats what happens when you just copy paste from a book instead of writing it yourself. These - “ “ mean nothing in c++ as far as Im aware. You have to use these - " "
Having the same exact problem with this line of code too.
// listing 2.2 using std::cout
#include <iostream>
int main()
{
std::cout << "Hello there. \";
std::cout << "Here is 5: " << 5 << "\n";
std::cout << "The manipulator std::endl ";
std::cout << "Writes a new line to the screen.";
std::cout << std:: endl;
std::cout << "Here is a very big number:\t" << 70000;
std::cout << std::endl;
std::cout << "Here is the sum of 8 and 5:\t";
std::cout << 8+5 << std::endl;
std::cout << "here's a fraction:\t\t";;
std::cout << (float 5/8 << std::endl;
std::cout << "And a very very big number: \t";
std::cout << (double) 7000 * 7000 << std::endl:
std::cout << "Don't forget to replace Jesse Liberty ";
std::cout << "With your name...\n";
std::cout << "Jesse Liberty is a C++ programmer!\n";
return 0;
}