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
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started