Concept explainers
// This
// user-supplied number. It checks for division by zero
#include <iostream>
using namespace std;
int main()
double num1, num2, quotient;
cout << "Enter a number: ";
cin >> num1;
cout << "Enter another number:
cin >> num2;
if (num2 == 0)
cout << "Division by zero is not possible,
cout << "Please run the program again
cout << "and enter a number besides zero,
else
quotient = num1 I num2:
cout << "The quotient of " << num1 <<
cout << " divided by " << num2 <<
cout << quotient << endl;
return 0;
}
Want to see the full answer?
Check out a sample textbook solutionChapter 4 Solutions
STARTING OUT WITH C++FROM CONTROL STRU
Additional Engineering Textbook Solutions
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
C Programming Language
Java How To Program (Early Objects)
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Database Concepts (8th Edition)
Starting out with Visual C# (4th Edition)
- Computer Fundamentals and Programming 2 Write a program that determines a student’s grade. The program will accept 3 scores and computes the average score. Determine the grade based on the following rules: - If the average score is equal or greater than 90, the grade is A. - If the average score is greater than or equal to 70 and less than 90, the grade is B. - If the average score is greater than or equal to 50 and less than 70, the grade is C. - If the average score is less than 50, the grade is F. Source Codes and Print Screen of the Outputarrow_forward// Calculator.cpp - This program performs arithmetic, ( +. -, *. / ) on two numbers.// Input: Interactive// Output: Result of arithmetic operation#include <iostream>#include <string>using namespace std;// Write performOperation() function declaration hereint main() { double numberOne, numberTwo; string operation; double result; cout << "Enter the first number: "; cin >> numberOne; cout << "Enter the second number: "; cin >> numberTwo; cout << "Enter an operator (+.-.*,/): "; cin >> operation; // Call performOperation method here cout << numberOne; cout << " " << operation << " "; cout << numberTwo; cout << " = "; cout << result << endl; return 0;} // End of main() function// Write performOperation function herearrow_forwardmy_round(number, integer): Based on the built-in round(...) function. Takes an integer or float and returns a rounded float value that is the number rounded to the second argument's decimal place. First argument can be any float or integer. Second argument must be an integer. Examples: my_round(1234.5678, 2) and round(1234.5678, 2) should return 1234.57. my_round(1234.5678, -2) and round(1234.5678, -2) should return 1200.0.arrow_forward
- Q- Write a program which defines three integer variables, var1, var2 and var3, & initializing them to the values 100, 200 & 300, it then prints out their addresses. Subject: C++arrow_forwardRe-type the code and fix any errors. The code should convert non-positive numbers to 1. if (userNum > 0) cout << "Positive." << endl; else cout << "Not positive, converting to 1." << endl; userNum = 1; cout << "Final: " << userNum << endl; #include <iostream>using namespace std; int main() { int userNum; cin >> userNum; /* Your code goes here */ return 0;}arrow_forwardc## please Write a Console Application that reads two integers, determines whether the first is a multiple of the second and displays the result. [Hint: Use the remainder operator.]arrow_forward
- 4.4 Arithmetic Operator #include <iostream>using namespace std;main (){ int a, b, c, sum; cout <<"An arithmetic operator program\n"; cout <<"\nenter first integer, a:"; cin >>a; cout <<"\nenter second integer, b:"; cin >> b; cout <<"\nenter thrid integer, c:"; cin >> c; sum = a * b - c % 3; cout << "\nthe sum of (a * b - c % 3) is " << sum << endl; return 0;} Can you predict what is the output will be before run the code?arrow_forwardNumber guessing Game Write a C program that implements the “guess my number” game. The computer chooses a random number using the following random generator function srand(time(NULL)); int r = rand() % 100 + 1; that creates a random number between 1 and 100 and puts it in the variable r. (Note that you have to include <time.h>) Then it asks the user to make a guess. Each time the user makes a guess, the program tells the user if the entered number is larger or smaller than its number. The user then keeps guessing till he/she finds the number. If the user doesn’t find the number after 10 guesses, a proper game over message will be shown and the actual guess is revealed. If the user makes a correct guess in its allowed 10 guesses, then a proper message will be shown and the number of guesses the user made to get the correct answer is also printed. After each correct guess or game over, the user decides to play again or quit and based on the user choice, the computer will make…arrow_forwardQuarterly Sales Create a program in c++ , that gets quarterly sales from a user and calculates the total of all four quarters as well as the average, lowest, and highest quarters. Console The Quarterly Sales program Enter sales for Q1: 12312.57 Enter sales for Q2: 15293.21 Enter sales for Q3: 14920.95 Enter sales for Q4: 23432.21 Total: 65958.94 Average Quarter: 16489.74 Lowest Quarter: 12312.57 Highest Quarter: 23432.21 Specifications Create the pseudocode needed to implement the solution above. Convert your pseudocode to C++ code including the following specifications: Round the average quarter to a maximum of 2 decimal digits. Use a vector to store the sales for each quarter. Use STL algorithms to process the data for the quarters.arrow_forward
- 8 -) Enter the C code for a 1-6 digit number that the user will enter from the keyboard,adds a number for each digit of this number, and if the result doubles, the total number is obtainedthe result and continues the program; if it is bot, it ends the program in the revelant place.arrow_forward// LargeSmall.cpp - This program calculates the largest and smallest of three integer values. #include <iostream> using namespace std; int main() { // This is the work done in the housekeeping() function // Declare and initialize variables here int largest; // Largest of the three values int smallest; // Smallest of the three values // Prompt the user to enter 3 integer values // Write assignment, add conditional statements here as appropriate // This is the work done in the endOfJob() function // Output largest and smallest number. cout << "The largest value is " << largest << endl; cout << "The smallest value is " << smallest << endl; return 0; }arrow_forwardNice Number Programming: Nice program ask user to enter three integers from keyboard (java console), the three integers represent left bound, right bound and arbitrary digit 'm', where left bound is less than right bound. Program should print all nice numbers in the given range that doesn't contain digit 'm'. The number is nice if its every digit is larger than the sum of digits which are on the right side of that digit. For example 741 is a nice number since 4> 1, and 7> 4+1. with digit m=2. Write a complete program in Java that Call only One method (niceNumbers method) that will print all nice numbers excluding a given digit 'm' that also entered by user?arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage