Homework help with integers.

Hi! my professor gave us this assignment without really instructing us on how it's done. I have a small idea of how it goes but I was wondering if someone could help me. Here are the instructions:

Write a program that prompts the user for and input two integer values. Perform operations below upon the two integer variables holding the inputted values.  Display the results of each operation, using these two values as operands.  Show the operands, the operators, and the result for each operation below.
first + second
first - second
first * second
first / second
first % second
To me, It's quite obvious what your professor is expecting. The instruction seems quite straight forward...
Since It's your homework I'll try to give you a clue.


int x, y;

// get input here

std::cout << x (operator) y;

Good luck - Isak
Last edited on
Hello marygamess,

Welcome to the forum.

And if you are unfamiliar with posting code.

PLEASE ALWAYS USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
Hint: You can edit your post, highlight your code and press the <> formatting button.
You can use the preview button at the bottom to see how it looks.

What you are asking for is what many have done before. Try a search here on "basic calculator".

Think about what you are being asked to do. You will need to input two numbers and an operator (+, - ,*, /, %), a switch/case will be useful.

Remember to initialize your variables when you define them. Always a good practice.

I will also mention that using namespace std; may be easy, but is a bad idea as it WILL be a problem someday.

Work up some code and post it with any questions or problems that you have. Many here will help you understand what you are doing wrong. And I will do all I can to help you,but first I need to know what you have learned so far.

Hope that helps,

Topic archived. No new replies allowed.