Question: C exercise #include // standard library for screen input/output int main() { int number = 1; int sum; // sum the numbers 1 to 5

C exercise

#include // standard library for screen input/output int main() { int number = 1; int sum; // sum the numbers 1 to 5 while(numaber < 5) {

sum=number number = number + 1; } // display result printf(" The sum of 1 to 5 is %d",sum); // keep console window on screen printf(" Press ENTER to continue..."); getchar(); // return from main routine (end of program) return(0); }

Fix the syntax errors (there are 2). Run the program. Although the program runs, notice that the output is not correct. The code logic is poorly written and the variable sum is not used correctly. Debug the program using the instructions outlined in 4.2.1 below. Start by placing a breakpoint on the line: int sum; // see breakpoints below Watch the values of the variables sum and number. See if you can find the problem(s) and add comment blocks.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!