$1.00

or free if you
register a new account!

Subject Computer Science C-Family Programming Keywords
C++
Computer Science
Algorithm
Integers
Sum
Difference
Product
Quotient
Question
Write the code and trace for the following:
1. Design an algorithm that will receive input of two integers and display to the screen their sum, difference, product, and quotient. Do not allow division by zero to occur.

2. Design an algorithm that will read two numbers and an integer code from the screen (print a menu of the choices first). If the code is 1, compute the sum of the two numbers. If the code is 2, compute the difference of the first number minus the second. If the code is 3, compute the product. If the code is 4 and the second number is not 0, compute the quotient (divide the first number by the second). If the code is not 1,2,3, or 4, display an error message. Finally, display the two numbers, the code, and the result (echo the input).
Solution
#include <cstdlib>
#include <iostream>
using namespace std;

/*
*
*/
int main(int argc, char** argv) {
   
    int integer1;
    int integer2 = 0;
    cout<<"Enter the first integers: ";
    cin>>integer1;
    while (integer2 == 0) {
       cout<<"Enter the second integers: ";
       cin>>integer2;
    }...

This is only a preview of the solution. Please use the purchase button to see the entire solution

Related Homework Solutions

Get help from a qualified tutor
Live Chats