For this task, I’m fortunate I had a bit of previous experience with programming, so I was just about remembering.

So here are a few advices:

  • Remember to always use the “<<” (without the quote marks, of course) before writing anything you want to output, if it’s text, using the quote marks (“… “); and if it’s the result of an operation (5*3 for example), like in this case, without them.
  • Never forget to put the semicolon (;) when you terminate a statement.
  • If you’re declaring a variable, use int for an integer variable; and char for characters, that two are the first you should know at the beginning.
  • When you want to give a value to a variable, use cin >> x (or however you want to call the variable), which you were supposed to declare before.
  • The operator you have to use to get the reminder of a division is “%” which is called modulus.
  • If you need more help, make sure to visit this page: http://www.lynda.com/C-tutorials/C-Essential-Training/182674-2.html  there is a useful video course to learn the basics of c++.
  • Also check the chapters 2 and 3 in your textbook “How to Think Like a Computer Scientist, C++ Version”, Downey, Allen B. 2012.

#include <iostream>

using namespace std;

int main () {

int x;

int y;

cout << “Introduce the first number:”;

cin >> x;

cout << “Introduce the second number:”;

cin >> y;

cout << “x + y =”<< (x + y) <<endl;

cout << “x – y =” << (x – y) <<endl;

cout <<“x * y =” << (x * y) <<endl;

cout << “x / y =” << (x / y) << endl;

cout << “The reminder of the division x / y is: ” << (x%y) << endl;

return 0;  }

And that’s it, it gets easier when you find the logic in all the code. I hope this post helps you.

CC BY 4.0 #WSQ03 Fun With Numbers by eduardomacielm is licensed under a Creative Commons Attribution 4.0 International License.