Concept explainers
What output will be produced by the following code, when embedded in a complete
int x = SOME_CONSTANT;
cout << “Start\n”;
if (x < 100)
cout << “First Output. \n”;
else if (x > 100)
cout << “Second Output. \n”;
else
cout << x << endl;
cout << “End\n”;
SOME_CONSTANT is a constant of type int. Assume that neither “First Output” nor “Second Output” is output. So, you know the value of x is output.
Want to see the full answer?
Check out a sample textbook solutionChapter 3 Solutions
Problem Solving with C++ (9th Edition)
Additional Engineering Textbook Solutions
Introduction to Programming Using Visual Basic (10th Edition)
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Starting Out with Programming Logic and Design (4th Edition)
Starting Out with Python (4th Edition)
Java How To Program (Early Objects)
- Write a statement to add the key Tesla with value USA to car_makers. Modify the car maker of Fiat to Italy. Sample output for the given program: Acura made in Japan Fiat made in Italy Tesla made in USA Code writing challenge activity demo 461710 3116374.qx3zqy7 1 car_makers {'Acura': 'Japan', 'Fiat': 'Egypt'} 2 3 # Add the key Tesla with value USA to car_makers 4# Modify the car maker of Fiat to Italy 5 6 "Your solution goes here ''' 7 8 print (f'Acura made in {car_makers ["Acura"]}') 9 print (f'Fiat made in {car_makers ["Fiat"]}') 10 print (f'Tesla made in {car_makers ["Tesla"]}') I =arrow_forwardThe value of a will become 3: int x = 2; x++; int a = (!5 == 5 + 2) ? 3>x ? 3: 5 : 4; cout << x; Select one: O True Falsearrow_forwardCan write a description for this code Code is located below: # initialize a flag variable with 0flag = 0 # loop will execute till flag is 0 in the sense loop will execute codewhile flag == 0 : #until amount is greater then costcost = float(input("Enter the cost: ")) # take input cost and convert to floating data typeamount = float(input("Enter the amount given(should be greater than cost): ")) # take inputif amount < cost :print("Amount should be greater than cost.") #print statement saying enter Amount thatelse:flag = 1 # when amount entered by user greater then cost flag is set to 1 and while loop will not execute change = amount-cost #stored difference between amount and cost to change variableprint(f"The change to be given is ${change}") #print the value of change variable twenty=0 #intializing all possible coin/ notes to 0ten=0five=0single=0quarter=0dime=0nickel=0penny=0 while change>=20 : #loop will execute until change become less then 20. this loop execute for…arrow_forward
- The program segment has errors. Find as many as you can. // This code should use a loop to raise a number to a power. int num, bigNum, power, count;cout << "Enter an integer: "; cin >> num; cout << "What power do you want it raised to? "; cin >> power; bigNum = num; while (count++ < power); bigNum *= num; cout << "The result is << bigNum << end1;arrow_forwardGiven integer napkinsOrdered, output: "Medium carton", if there are 50 - 80 napkins inclusive. "Large carton", if there are 120 - 150 napkins inclusive. End each output with a newline. Ex: If the input is 141, then the output is: Large carton #include <iostream>using namespace std; int main() { int napkinsOrdered; cin >> napkinsOrdered; /* Your code goes here */ return 0;}arrow_forwardwhat is the output of the following code segment? int x = 350; int y = 0; do { y +=x 0; X = x/10; } while (x!=0); cout<arrow_forward
- User Prompts Your program will allow a human user to play Rock, Paper, Scissors with the computer. At the beginning of the game, the user should be prompted for his/her input. The valid choices for input are:• R or r (Rock)• P or p (Paper)• S or s (Scissors)• Q or q (Quit) Beginning of Round At the beginning of each round your program should ask the user for an input. Invalid Entry If the user inputs something other than r, R, p, P, s, S, q or Q, the program should detect the invalid entry and ask the user to make another choice. Round structure Each round of the game will have the following structure:1. The program will choose a weapon (Rock, Paper, Scissors), but its choice will not be displayed until later so the user doesn’t see it.2. The program will announce the beginning of the round and ask the user for his/her weapon choice3. The two weapons will be compared to determine the winner (or a tie) and the results will be displayed by the program4. The next round will…arrow_forward1- What is the output of the following code: k=0;i=0; while(k<1 && i<1) k=k+1; i=i+1;i-i-k; end O i=0, k=1 O i=0, k=0 O i=1, k=0 O i=1, k=1arrow_forward6. Which of the below code contains correct overloading code? Why would the other won't work? Code 1 double myMultiply. (int x){ return 10 x; Code 2 int awMultielx (int x){ return 10 x; } double yMultirly. (double x){ double yMultiely (int x){ return 20 x; return 2e * x; 7. What would be the output for the following program and why ( explain in short): Bublis static void nain(String acsal))( String."; String si - "Testing Java Program String s2 - sukstriui13); 8. Write the code in Java for the following class from the UML diagram below: Vehicle -passengers: int -maxSpeed: double -color: String +Vehiclelint,double.String) +setColor(): void +getColor(): String +findCaracityl): double The findCapacityl) method return the capacity of the vehicle by the following formula: Capacity = passengers * 75 L0.20 * maxSpeed)arrow_forward
- Write a program that will enter the amount loan and mode of payment code and will output the the following: • amount loan • type of loan • total interest = amount loan * interest rate * no. of months • total amount due= amount loan + total interest • monthly due= total amount due/no of months Mode of payment code type of loan interest 1 short-term (6 months) 7% monthly 2 longterm ( 1 year) 5%monthlyarrow_forwardProgramming Language: Java Direction: Write a program to determine the number of PASSED and FAILED out of 15 inputted names with the corresponding grade. Restrict the inputted grade for each name in the range of 50 to 100, in which 75 is the passing grade. If the inputted grade is not on the range, the program will remind the user of a message for the accepted range for the grade and allows the user to re-enter a grade. NOTE: MUST ADD COMMENTSarrow_forwardThere are THREE errors in the code below. % Clear variables from workspace clear b = [2 5 7 10]; C = 3; d = linspace(0, 20, 25); for n = 1:1:length(b) for m = 1:1:length(d) if d(1,m) >= e && d(1,m) = 5 && d(1,m) < 15 x(n,m) = c*b; % Error 2 %3D else x(m,n) = c*b(1,n)+d(1,m)^3; % Error 3 end end end Correct the THREE errors in the code below.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