Rusty keys

#WSQ03 #WSQ1017

For this next program we were instructed to make some basic operations out of two numbers given by the user. It was completed almost with ease, and I say almost because I had to recheck some basic stuff such as the predecence of operators and some syntaxs rules when using cout and cin. This was achieved thanks to the ebook referred in the syllabus.

Below we can see both the source code and the running program:

proof_op.PNG

Source code:

#include <iostream>
using namespace std;

int firstnumber;
int secondnumber;

int main(){

cout << “Reminder: This program only accepts integer numbers” << endl;
cout << endl;
cout <<“Please enter the first number:”<< endl;
cin >> firstnumber;
cout << “Please enter the second number: “<< endl;
cin >> secondnumber;
cout << endl;

cout <<“The difference between your first number and your second number is: “;
cout << firstnumber – secondnumber << endl;
cout << endl;
cout <<“The difference between your second number and your first number is: “;
cout << secondnumber – firstnumber << endl;
cout << endl;

cout <<“The product of both numbers is: “;
cout << firstnumber*secondnumber <<endl;
cout << endl;

cout <<“The result of your first number divided by the second is: “;
cout << firstnumber/secondnumber << endl;
cout << endl;

cout <<“The remainder of the division is: “;
cout << firstnumber%secondnumber << endl;

}

———

Photo Credit: <a href=”https://www.flickr.com/photos/42333408@N02/6248243245/”>Felipe_Borges</a&gt; via <a href=”http://compfight.com”>Compfight</a&gt; <a href=”https://creativecommons.org/licenses/by-nc-nd/2.0/”>cc</a&gt;

CC BY-SA 4.0 Rusty keys by diegodamy is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.