This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: new y value which is equal to y*i. It then increases the value of i AFTER it determines the new value of y and increase i until it is equal to 4. The y values in order are as follows y=y*1 y=(3*2)=6 y=(6*3)=18 y=(18*4)=72 This is where the program stops because i is equal to 4 The final display answer is: The result is 72 Problem 5: Error 1: In the for loop there should be a semicolon after i=2 and i>8 Error 2: Instead of x=+1, it should be x+=i Error 3: In the for loop you have to start I out at 1 instead of 2; if you run the program like it is now it would exclude the value of 1 to the sum of the intgers Error 4: I has to be i<8, not i>8 because you are looking for the sum of the numbers before I reaches 8 The output of the program then becomes The sum of integers 1 to 7 is 28; Old Program = New program =...
View
Full
Document
This note was uploaded on 02/01/2009 for the course ENGR 001 taught by Professor Dr.smith during the Spring '08 term at Lehigh University .
 Spring '08
 Dr.Smith

Click to edit the document details