Subject Computer Science C-Family Programming

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 Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

#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

$13.00

or free if you
register a new account!

Assisting Tutor

Related Homework Solutions

Get help from a qualified tutor
Live Chats