Use nested loops and the code from Lab Project 21 (a childish sum) to produce the output below. The outer loop control variable can be used to help display the output the inner loop. 30 The sum of positive integers from 1 to 1 is 1 The sum of positive integers from 1 to 2 is 3 The sum of positive integers from 1 to 3 is 6 The sum of positive integers from 1 to 4 is 10 The sum of positive integers from 1 to 5 is 15 output for integers 16 to 99. The sum of positive integers from 1 to 100 is 5050 Because we already have a program that computes 1+2+-+n for any positive integer n, we can embed that code in a second auter loop that loops 100 times. The outer loop control variable can be used to control the number of times we loop and more importantly, it can be used to control the upper limit of the inner computation
Use nested loops and the code from Lab Project 21 (a childish sum) to produce the output below. The outer loop control variable can be used to help display the output the inner loop. 30 The sum of positive integers from 1 to 1 is 1 The sum of positive integers from 1 to 2 is 3 The sum of positive integers from 1 to 3 is 6 The sum of positive integers from 1 to 4 is 10 The sum of positive integers from 1 to 5 is 15 output for integers 16 to 99. The sum of positive integers from 1 to 100 is 5050 Because we already have a program that computes 1+2+-+n for any positive integer n, we can embed that code in a second auter loop that loops 100 times. The outer loop control variable can be used to control the number of times we loop and more importantly, it can be used to control the upper limit of the inner computation
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 4 images