Hi again! This post is about WSQ05, which can be called WSQ01.2, too. This because is the same program we did in the first assignment, but now we write a function for each calculation (which is pretty easy, by the way). The only thing you need to be careful with is the name of the variables. You cannot directly call the result of the function to print it, you need to store it in a variable first, and then print it.


using namespace std;

int sum(int n1, int n2)
int dif(int n1,int n2)
int pro(int n1, int n2)
int divi(int n1, int n2)
int mod(int n1, int n2)

int main()
int n1,n2;
cout<<“This program gives you the sum, difference, multiplication, division and the remainder of two given numbers.”<<endl;
cout<<“Please insert the first number:”<<endl; cin>>n1;
cout<<“Please insert the second number:”<<endl; cin>>n2;
int s=sum(n1,n2);
int d=dif(n1,n2);
int p=pro(n1,n2);
int di=divi(n1,n2);
int m=mod(n1,n2);
cout<<“The result of the sum is “<<s<<“.”<<endl;
cout<<“The result of the difference is “<<d<<“.”<<endl;
cout<<“The result of the product is “<<p<<“.”<<endl;
cout<<“The result of the division is “<<di<<“.”<<endl;
cout<<“The remainder of the division is “<<m<<“.”<<endl;
return 0;



One comment on “#WSQ05

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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s