Concept explainers
Write a for loop that calculates the total of the following series of numbers:
Want to see the full answer?
Check out a sample textbook solutionChapter 5 Solutions
Starting Out with C++: Early Objects Plus MyLab Programming with Pearson eText -- Access Card Package (9th Edition)
Additional Engineering Textbook Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Starting Out with Python (3rd Edition)
Problem Solving with C++ (9th Edition)
Java: An Introduction to Problem Solving and Programming (7th Edition)
Modern Database Management (12th Edition)
- Write a while loop that prints userNum divided by 4 (integer division) until reaching 2 or less. Follow each number by a space. Example output for userNum = 160:40 10 2arrow_forwardWrite a for loop that displays the following set of numbers: 4 8 16 32 64 128 256 512 1024arrow_forwardWrite a loop that calculates the total of the following series of numbers: 1/30+2/29+3/28+.....30/1arrow_forward
- Given the following for loop, rewrite it as a do..while loop that performs the same operation: int count = 1, inc; for (inc = 3; inc <=5; inc++) { if (inc <5) count += inc; else count = inc; count += 2; } cout<<count;arrow_forwardWrite a for loop that prints 10 8 6 4 2 0arrow_forwardThe following while loop should be converted to a for loop: I = ten whereas i250 is equal to I print out I Equals I plus 50arrow_forward
- Ask the user how many integers that he/she wants to enter. Using a for loop, ask the user for that many integers. Then, display all those integers.arrow_forwardassuming the variable num has been defined, write a for loop that displays all the odd numbers from 3 to 23.arrow_forwardWrite a for loop that prints the multiples of 3 from 300 down to 3.arrow_forward
- C++ 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_forwardUsing a Java application write a for loop to sum all the squares of numbers between 1 and 15. Output the sum.arrow_forwardGiven positive integer numInsects, write a while loop that prints that number doubled without reaching 200. Follow each number with a space. After the loop, print a newline. Ex: If numInsects = 16, print:16 32 64 128 c++arrow_forward
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr