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

Assisting Tutor

Related Homework Solutions

Programming Problems
Homework Solution
$50.00
Programming
C
Computer Science
Sorting
Integers
Arrays
Statements
Variables
Loops
Functions
Input
Output
Echo
Unix Commands
Memory
Strings
Line Arguments
Duplicates
Attributes & Methods in C++
Homework Solution
$10.00
Programming
C++
Computer Science
Attributes
Methods
Students
People
Inheritance
Employees
Salaries
Job Titles
Classes
Statements
Variables
Programming Questions
Homework Solution
$20.00
Programming
C++
Computer Science
Integers
Series
Savings Accounts
Balance
Loops
Statements
Variables
Interest Rates
Deposits
Withdrawals
Input
Output
Computer Science Questions
Homework Solution
$10.00
Computer Science
Students
Programming
ID Numbers
Classes
Major Codes
Variables
Loops
Conditions
Strings
Algorithms
Get help from a qualified tutor
Live Chats