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

(a) Develop a flowchart and then write a C++ program to solve the following prog

ID: 669891 • Letter: #

Question


 

(a) Develop a flowchart and then write a C++ program to solve the following program.

Upon execution of the program, your name will be displayed, properly centered.

(b) The program will then prompt the user for two long integer input and the program will then compute the difference and the quotient of the two numbers and produce the results of both operations with appropriate labels. See sample output for the addition operation below. The output assumes x = 5, and y = 10.

 Difference of x and  y  is equal to  x - y  or 5 - 10  and the result is -5
The format for the quotient as a result of the division is the same.

 

(c)The program will then use the same two integer numbers and perform the following operations. The program displays the relations between the two numbers for the following relational operators:

<, >=, !=

 

Each of these operators requires two operands: use the first integer number as the first operand and the second integer number as the second operand. See sample of output desired below.

x >= y is  5 >= 10 and the result is 0

where x is the first number and y is the second number. Your solution will work for any two long integer numbers.

 

The format for other operators listed is the same.

 

(d) The program will then use the same two integer numbers and computes different operations using the following arithmetic assignment operators:

+=, *=, %=

The result of these operations is stored in the first operand. See example below.

x += y is 5 += 10 and the result is x = 15

or

x *= y is 15 *= 10 and the result is x= 150

HINTS:

1. Your program will only have one main() function, one return statement, and anything declared globally, like #include <iostream>. Parts b, c, and d are part of one .cpp file.

2. Make sure your program  executes correctly

3. Make sure the variables are correctly declared without any conflicts with other variables. You may have to change some of the variables to make each variable unique.

4. You need to run the program four times for the numbers shown below.

 

Test your program with the following sets of numbers:

First number, Second number

5  ,10

-10  ,15

15,  -20

-10 , -25

Explanation / Answer

a)
#include <bits/stdc++.h>
using namespace std;

int main(){
   string name;
   cout << "Enter your name : ";
   cin >> name;
   cout << name << endl;
   return 0;
}


b)
#include <bits/stdc++.h>
using namespace std;

int main(){
   long long int x,y;
   cout << "Enter x and y separated by space ";
   cin >> x >> y;
   cout << "Difference of x and y is equal to x-y or " << x << " - " << y << " and result is " << (x-y) << endl;
   cout << "Difference of x and y is equal to x/y or " << x << " / " << y << " and result is " << (x/y) << endl;
   return 0;
}

c)

#include <bits/stdc++.h>
using namespace std;

int main(){
   long long int x,y;
   cout << "Enter x and y separated by space ";
   cin >> x >> y;
   int a = 0, b = 0, c = 9;
   if (x >= y) a = 1;
   if (x != y) b = 1;
   if (x < y) c = 1;
   cout << "x >= y is " << x " >= " << y << " and the result is " << a << endl;
   cout << "x != y is " << x " != " << y << " and the result is " << b << endl;
   cout << "x < y is " << x " < " << y << " and the result is " << c << endl;
   return 0;

}

d)

#include <bits/stdc++.h>
using namespace std;

int main(){
   long long int x,y;
   cout << "Enter x and y separated by space ";
   cin >> x >> y;
   int a = x + y;
   int b = x * y;
   int c = x % y;
   cout << "x += y is " << x " += " << y << " and the result is " << a << endl;
   cout << "x *= y is " << x " *= " << y << " and the result is " << b << endl;
   cout << "x %= y is " << x " %= " << y << " and the result is " << c << endl;
   return 0;
}