Concept explainers
What will the output of the following
#include <iostream>
using namespace std;
void func1()
{
cout ≪ "Able was I\n";
}
void func2()
{
cout ≪ "I saw Elba\n";
}
int main()
{
int input;
cout ≪ "Enter a number: ";
cin ≫ input;
if (input < 10)
{
func1();
func2();
}
else
{
func2();
func1();
}
return 0;
}
Trending nowThis is a popular solution!
Learn your wayIncludes step-by-step video
Chapter 6 Solutions
Starting Out with C++ from Control Structures to Objects (8th Edition)
Additional Engineering Textbook Solutions
Java How To Program (Early Objects)
Starting Out with Python (4th Edition)
Starting Out with Python (3rd Edition)
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
Concepts Of Programming Languages
Starting Out with Java: From Control Structures through Objects (6th Edition)
- 4.20 LAB: Warm up: Automobile service cost (1) Prompt the user for an automobile service. Output the user's input. (1 pt)Ex: Enter desired auto service: Oil change You entered: Oil change (2) Output the price of the requested service. (4 pts)Ex: Enter desired auto service: Oil change You entered: Oil change Cost of oil change: $35 The program should support the following services (all integers): Oil change -- $35 Tire rotation -- $19 Car wash -- $7 If the user enters a service that is not listed above, then output the following error message: Error: Requested service is not recognized 344614.2153518.qx3zqy7 Use Python for this please.arrow_forwardFirst, write code that uses cin to read in a value for numLimes from input. Then, write code that uses cout to output "I bought ", the variable numLimes, and " limes." End with a newline. Ex: If the input is 6, then the output is: I bought 6 limes. Ex: If the input is 8, then the output is: I bought 8 limes. #include <iostream>using namespace std; int main() { int numLimes; /* Your code goes here */ return 0;}arrow_forwardQuestion 5 What is the output of the following code segment? int num cin>>x; = 20, 5, X; if (x >= 2*num) y+=1; else if (x >= num) y+=2; if (xarrow_forward
- int main() { E(); C(); E(); } void B() {...} void C() {..} void D() {..} void E() { B(); D(); } A variable declared in function B and only in function B is accessible in?arrow_forwardWhat is the output of the following code segment? int n = 1;do { cout << n << ' '; n++; } while (n >= 5) What is the output of the following code segment? int n = 1;do { cout << n << ' '; n++; } while (n <= 5);arrow_forwardCorrect answer will be Upvoted else downvoted. Thank you! What will be the output of the following C++ code? #include <iomanip>#include <iostream>using namespace std;int main(){cout << setprecision(17);double d = 0.1;cout << d << endl;return 0;}arrow_forward
- (TCO 2) What is the output of the following program? int number = 25; int *var = &number; cout << *var << endl;arrow_forwardWhat is the output of the following program? #include <iostream> Using namespace std; void figure_me_out (int x, int y, int z); int a = 10, c = 30; int main () { int b = 20; figure_me_out (a, b, c); cout << a << “ “ << b << “ “ << c; return 0; } void figure_me_out (int x, int y, int z) { cout << x << “ “ << y << “ “ << z << endl; a = 1; y = 2; c = 3; cout << x << “ “ << y << “ “ << z << endl; }arrow_forwardWhat is the output? #include <stdio.h> int main(void) { double dividend = 0.0; double divisor = 0.0; printf("%lf\n", dividend / divisor); dividend = 3.0; printf("%lf\n", dividend / divisor); return 0; } Question 5 options: inf nan nan inf inf 0.0 nan 0.0arrow_forward
- First, write code that uses cin to read in a value for numTomatoes from input. Then, write code that uses cout to output "She sold me ", the variable numTomatoes, and " tomatoes." End with a newline. Ex: If the input is 8, then the output is: She sold me 8 tomatoes. Ex: If the input is 9, then the output is: She sold me 9 tomatoes #include <iostream>using namespace std; int main() { int numTomatoes; /* Your code goes here */ return 0;}arrow_forward// Cornwall.cpp - This program computes hotel guest rates.// Input: None// Output: Hotel guest rate#include <iostream>#include <string>using namespace std;double computeRate(int);double computeRate(int, string);int main() { int days; string mealPlan; string question; double rate = 0.0; cout << "How many days do you plan to stay? " << endl; cin >> days; cout << "Do you want a meal plan? Y or N: " << endl; cin >> question; // Figure out which arguments to pass to the computeRate() function and // then call the computeRate() function cout << "The rate for your stay is $" << rate << endl; return 0;} // End of main() function// Write computeRate functions here.arrow_forwardWhat is the output of the following C++ code? (2, 3) Submit your answer to dropbox. int num=1; while(num*num<=50) { cout<<num<<""; num=num+2; } cout<<endl;arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education