Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Next Generation Databases NoSQLand Big Data

Authors: Guy Harrison

1st Edition

1484213300, 978-1484213308

More Books

Students also viewed these Databases questions