Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

int a = 20, b = 7; double x = 20, y = 7, z = 0; c++ pls The program must output

ID: 3661910 • Letter: I

Question

int a = 20, b = 7; double x = 20, y = 7, z = 0; c++ pls

The program must output the sum of a and b, the difference a minus b, the difference b minus a,the product a times b, the quotient a divided by b, the quotient x divided by y, the remainder a mod b, and the remainder b mod a. You must output the results in order on separate lines. In writing the program, use variable names in the calculations and the cout statements. Do not hard code any numeric literals other than in the definitions specified above (use a + b not 20 + 7). Use the variable z to store the results of the calculations.

Explanation / Answer

Program : ArthematicOperations.cpp

# include <iostream>
using namespace std;
int main(){ //main function
   int a=20,b=7; //declaring the varibles as a integers
   double x=20, y=7, z=0; //declaring the varibles as a double
   z=a+b; //addition operation on a and b
   cout<<z<<endl;//z=27
   z=a-b;//substraction operation on a and b
   cout<<z<<endl;//z=13
   z=b-a;//substract operation on b and a
   cout<<z<<endl;//z=-13
   z=a*b; //multiplication operation on a and b
   cout<<z<<endl;//z=140
   z=a/b;//division operation on and b
   cout<<z<<endl;//z=2
   z=x/y;//division operation on x and y
   cout<<x/y<<endl;//z=2.85714
   z=a%b;//modulo operation on a and b
   cout<<a%b<<endl;//z=6
   z=b%a;//modulao operation on b and a
   cout<<b%a<<endl;//z=7
   }

Expected output :

27
13
-13
140
2
2.85714
6
7

--------------------------------
Process exited with return value 0
Press any key to continue . . .