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 Structures through Objects, Brief Version plus MyLab Programming with Pearson eText - Access Card Package (8th Edition)
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)
- // 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_forward// SumAndProduct.cpp - This program computes sums and products // Input: Interactive// Output: Computed sum and product #include <iostream>#include <string>void sums(int);void products(int);using namespace std; int main() { int number; cout << "Enter a positive integer or 0 to quit: "; cin >> number; while(number != 0) { // Call sums function here // Call products function here cout << "Enter a positive integer or 0 to quit: "; cin >> number; } return 0;} // End of main function// Write sums function here// Write products function herearrow_forward#include #include #include #include #include using namespace std; int main (){ const double PI = 3.14159265359; return 0; }arrow_forward
- c code Screenshot and output is mustarrow_forward/* Program Name: BadDate.cpp Function: This program determines if a date entered by the user is valid. Input: Interactive Output: Valid date is printed or user is alerted that an invalid date was entered */ #include <iostream> bool validateDate(int, int, int); using namespace std; int main() { // Declare variables int year; int month; int day; const int MIN_YEAR = 0, MIN_MONTH = 1, MAX_MONTH = 12, MIN_DAY = 1, MAX_DAY = 31; bool validDate = true; // This is the work of the housekeeping() method // Get the year, then the month, then the day // This is the work of the detailLoop() method // Check to be sure date is valid if(year <= MIN_YEAR) // invalid year validDate = false; else if (month < MIN_MONTH || month > MAX_MONTH) // invalid month validDate = false; else if (day < MIN_DAY || day > MAX_DAY) // invalid day validDate = false; // This is the work of the endOfJob()…arrow_forwardvoid funOne(int a, int& b, char v); void main() { int num1=10; char ch='A'; funOne(num1, 15,ch)<arrow_forward#include using namespace std; int main() int x=1,y=2; for (int i=0; i<3; i++) e{ x=x*y; 8{ } cout<arrow_forwardNonearrow_forward#include using namespace std; int main () int x, y; { X = 5; y = ++x cout << x << y; %3D ++x; %3D x = 5; y = x++ * ++x; cout << x < y; return e; } 525636 747953 749735 636636arrow_forward// Swap.cpp - This program determines the minimum and maximum of three values input by // the user and performs necessary swaps. // Input: Three int values. // Output: The numbers in numerical order. #include <iostream> using namespace std; int main() { // Declare variables int first = 0; // First number int second = 0; // Second number int third = 0; // Third number int temp; // Used to swap numbers const string SENTINEL = "done"; // Named constant for sentinel value string repeat; bool notDone = true; //loop control // Get user input cout << "Enter first number: "; cin >> first; cout << "Enter second number: "; cin >> second; cout << "Enter third number: "; cin >> third; while(notDone == true){ // Test to see if the first number is greater than the second number // Test to see if the second number is greater than the third number // Test to…arrow_forward#include using namespace std; int main() 3 { int x,y; or (x=0; x 3) break; cout << y << endl; }}} O O 10 O 5 04arrow_forwardC++arrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_iosRecommended textbooks for you
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage