In: Computer Science
You are required to write an interactive program that prompts the user for two integers X and Y and performs the following tasks:
Program requirements:
- The program should run as many times as the users wish
- The program should be fully documented.
- You must submit a hard copy of the source and a properly labeled output.
- You should submit a digital copy of source code (in class).
- Test your program for different values using different set of data that the users provide. .
NOTES: be sure to use basic functions of C++
(Not scan function)
USE: functions such as: using name space std, declare a main, int, loops, cin, cout, endl
be sure to comment within the program what is taking place and scentences such as:
"The sum of X and Y is:"
"The product of X and Y is:"
"The Larger number is:" (X or Y)
"Would you like to continue? (Press Y or yes or N for no. If No then program exits)
#include<iostream> //header file for performing i/o
operations
using namespace std;
int main()
{
//declare two variables;
int x,y;
//declare four variables for storing the results
int a,b,c,d;
//declare status variable
char ch;
do
{
cout<<"Enter x "<<endl;
cin>>x;
cout<<"Enter y "<<endl;
cin>>y;
a=x+y; //add two numbers x and y
b=x-y; //subtract two numbers x and y
c=x*y; //multiply x and y
d=x/y; //division of x and y
cout<<"The sum of X and Y is: "<<a<<endl;
cout<<"The difference of X and Y is:
"<<b<<endl;
cout<<"The product of X and Y is:
"<<c<<endl;
cout<<"The division of X and Y is:
"<<d<<endl;
if(x>y)
cout<<"The Largest number is X"<<endl;
else
cout<<"The Largest number is Y"<<endl;
cout<<"Would you like to continue? (Press Y for yes or N for
no) ";
cin>>ch;
}while(ch=='Y');
return 0;
}
Output