Concept explainers
You want to write a for loop that displays “I love to
A) What initialization expression will you use?
B) What test expression will you use?
C) What update expression will you use?
D) Write the loop.
Want to see the full answer?
Check out a sample textbook solutionChapter 5 Solutions
Starting Out with C++ from Control Structures to Objects, Student Value Edition plus MyProgrammingLab with Pearson eText -- Access Card Package (8th Edition)
Additional Engineering Textbook Solutions
Problem Solving with C++ (10th Edition)
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Database Concepts (7th Edition)
Java: An Introduction to Problem Solving and Programming (7th Edition)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Starting Out with C++: Early Objects (9th Edition)
- How many times will the following do loop execute and what is the output? i = 20; do { i = i/3; cout << << endl ; } while (i > 2);arrow_forwardThe main difference between using do/while loop and while loop is that while loop executes the code block once then it checked if the condition is true so it will repeat the loop. True Falsearrow_forwardThe "return 0" syntax will only terminate the loop, not the entire program. True Falsearrow_forward
- Write a for loop that repeats seven times, asking the user to enter a number. The loop should also calculate the sum of the numbers entered and display the final sum. Write a for loop that displays the following set of numbers: 0, 10, 20, 30, 40, 50 . . . 1000 What’s the initialization step? The Boolean test/condition? Update action/incrementation? Convert the while loop in the following code segment to a for loop: int count = 0; while (count < 50) { System.out.println("count is " + count); count++; } please solve three of themarrow_forwardC++ please! Write code with one while loop that prints out these 5 lines like this (remember a newline after each line): COUNTDOWN TO ZERO: 4 COUNTDOWN TO ZERO: 3 COUNTDOWN TO ZERO: 2 COUNTDOWN TO ZERO: 1 COUNTDOWN TO ZERO: LIFT OFF!arrow_forwardHow can you use the for loop to keep repeating the same statement?arrow_forward
- Which form of while loop uses a user-supplied character or value to exit the loop? While the loop eof, loop counter, and loop flag can be managed, and the loop sentinel can be monitored,arrow_forwardTask # 4: Write pseudo code for a program that uses while loop and: Takes 5 integers from user (both positive and negative). Gives the sum of all positive numbers. iii. Give the sum of all negative numbers. (Hint : Use while loop and if-else statements) Example: User input: 5 -7 1 2 -3 Positive sum = 8 Negative sum = -10. Write down c++ code and dry run it using the examples (You can use dev c++ for verifying your code).arrow_forwardWrite a loop that asks the user “Do you want to repeat the program or quit? (R/Q)”. The loop should repeat until the user has entered an R or Q (either uppercase or lowercase).arrow_forward
- . __________ is a keyword that is used to get out from the iteration of a loop immediately. a. continue b. break c. goto d. defaultarrow_forwardDo the problem than Modify the magic number so that the user gets 3 guesses to guesses to guess at the magic number instead of 1 guess. Use a for loop to control the number of guesses that the user has to guess at the magic number.arrow_forwardWhich kind of while loop may be broken by entering a single character or a single value into the input field? Although the loop eof, loop counter, and loop flag may all be managed, the loop sentinel cannot.arrow_forward
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning