Write a loop that calculates the total of the following series of numbers:
Want to see the full answer?
Check out a sample textbook solutionChapter 4 Solutions
Starting Out with Python plus MyProgrammingLab with Pearson eText -- Access Card Package (3rd Edition)
Additional Engineering Textbook Solutions
Modern Database Management (12th Edition)
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Java How To Program (Early Objects)
Starting out with Visual C# (4th Edition)
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
- n and limit are two integer variables. Write a while loop that prints the powers of n that are less than limit. (Example: if n = 4, limit = 1000, it will print 4 16 64 256. This is just an example for clarification.) Write only the statements to perform the above explained task, nothing else. Use while loop, don't use for loop.arrow_forwardYou need to write a loop that will repeat exactly 125 times. Which is the preferred loop construct to use? A. while B. do while loop C. for looparrow_forward|Question:: Write a loop to display the powers of 2 exactly as shown below: 2 4 8 16 32 64 128arrow_forward
- 2. Use any loop of your choice to print all numbers between 10 and 100 that are divisible by 5. Print the sum of all the numbers divisible by 5.arrow_forwardB2. Write a loop statement (NOT a complete program) to display all the numbers that are odd numbers between 1 and 50 inclusive. The loop should display the following numbers: 1 3 579 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49arrow_forwardQuestion#2. The distance a vehicle travels can be calculated as fallout: Distance = Speed * Time For example, if a train travels 60 miles-per-hour for three hours, the distance [raveled is 120 miles. Write a program that asks for the speed of a vehicle (in miles-per-hour) and the number of hours it has traveled. It should use a loop to display the distance a vehicle has traveled for each hour of a time period specified by the user. For example, if a vehicle is traveling at 40 mph far a three-hour time period, it should display a report similar to the one chat follows: Hour Distance Traveled 1 90 2 100 3 150 Input Validation: Do not accept a negative number for speed and do not accept any value les than 1 for time traveled.arrow_forward
- Convert the following while loop into a for loop i=1; while(i<100) { printf("%d\n",i); i*=3; }arrow_forward#1 Name Use a loop to write your name ten times #7 Namecount Redo #1 but every time you print your name out also print out the value of the loop counter(for example the first three lines might look like this) do this ten times Patti K 0 Patti K 1 Patti K 2arrow_forwardPart A: While Loop Program - using Java. Write a program that detects Fibonacci numbers. Prompt the user to input a positive integer. Upon input, the program will determine if the number is either a Fibonacci number or not. If a Fibonacci number, then the order of the number in the sequence must be output. If not a Fibonacci number, then the Fibonacci numbers above and below it (including their order in the sequence) must be output. Once it finishes, the program will prompt the user for a new number. The program will exit if the user enters a non-integer number or string (such as “quit”) instead of an integer. Use the sample output file, fib-seq-det.txt, to view a sample session Additionally: For both the above problems, the first four numbers of the Fibonacci sequence are: 0, 1, 1, and 2. Part A must use While loops onlyarrow_forward
- paython programing qustion Write a while loop that will print all the numbers between 200 and 300 (200 and 300 included) that are divisible by 3 but not divisible by 6. Your output should include the following numbers: 201 207 213 219 225 231 237 243 249 255 261 267 273 279 285 291 297arrow_forwardB2. Write a loop statement (NOT a complete program) to display all the numbers that are multiples of 4 between 1 and 100 inclusive. [2.5 marks] The loop should display the following numbers: 4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96 100arrow_forwardWe use For loop instead of a while loop when we know exactly how many times you want to loop through a block of code. True Falsearrow_forward
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,