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

Checkers Game Using Socket Communication
Homework Solution
$40.00
Programming
Computer Science
Checkers Game
Moves
Players
Codes
Rules
Statements
Variables
Functions
Socket Communication
Managers
Threads
Parent Process
Child Process
Results
Winners
Restaurant Waitlist Using C++
Homework Solution
$13.00
Programming
C++
Computer Science
Linked Lists
Queue
People
Restaurant Waitlist
Guests
Reservations
Statements
Variables
Data Sets
Constructors
Pointers
Search
Input
Output
Programming Problem: Skyline Buildings
Homework Solution
$8.00
Programming
C++
Skyline Buildings
Computer Science
Codes
XOR
Advertisement
Algorithms
Implementations
Languages
Classes
Area
Maximum Values
Corresponding Elements
Constraints
Statements
Variables
Programming Problem: Calories & Money
Homework Solution
$38.00
Computer Science
Codes
C++
Calories
Money
Input
Output
Food
Dynamic Programming
Arrays
Statements
Variables
Integers
Strings
File Management
Recurrence
C entsMemoized Implementation
Iterative Implementation
Algorithms
Get help from a qualified tutor
Live Chats