WSQ 01

Here you have it… WSQ 01. The program is very simple: You give the computer 2 numbers and the computer do different operations with them. In this program, there is no need to add additional libraries, you just use <iostream>. So here’s the code and how it works. If you have any questions, you can contact me in the twitter link on top of my blog.

Code:

#include <iostream>

using namespace std;

int main()
{
int n1, n2, sum, dif, pro, divi, rema;
cout<<“Give me two numbers and I’ll calculate its sum, difference, product, division and remainder from division.”<<endl;

cout<<“Give me your first number:”<<endl;
cin>>n1;
cout<<“Give me your second number:”<<endl;
cin>>n2;
sum=n1+n2;
cout<<“The result of the sum is “<<sum<<“.”<<endl;

dif=n1-n2;
cout<<“The result of the difference is “<<dif<<“.”<<endl;

pro=n1*n2;
cout<<“The result of the product is “<<pro<<“.”<<endl;

divi=n1/n2;
cout<<“The result of the division is “<<divi<<“.”<<endl;

rema=n1%n2;
cout<<“The remainder of the division is “<<rema<<“.”<<endl;
return 0;
}

wsq01

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s