LastName Unit2 GuidedPractice1

Step 1
The error in the code is “unexpected end of file found in comment”. It is occurring
because comment is not properly ended. Below is the correct code:
#include <stdio.h>
int main()
{
int i = 0;
i = i + 1;
printf("i to equal to 1");
/* comment */
}
Step 2
There is a logical error in the program printf statement only runs for single time and
loop executes itself repeatedly and does not enter the loop body because there is a
semi-colon after the loop statement.
To fix this, we will have to remove the semi-colon. Below is the correct code:
#include <stdio.h>
int main()
{
int i;
for (i = 0; i <= 10; i++);
{
printf("%d\n", i);
}
return 0;
}
Step 3
The output of the given code is “The last value of count is 5”. This executed as
below:
Initially value of count is 1, the while loop continue to execute the loop body as long
as the value of count is less than 5. Inside the body it increments the value of count
by 1. So each time value of count is incremented starting from 1 and as soon as it
becomes 5, loop terminated. Thus the value of count after the loop is 5 and so is the
output.

Place new order. It's free, fast and safe

-+
550 words

Our customers say

Customer Avatar
Jeff Curtis
USA, Student

"I'm fully satisfied with the essay I've just received. When I read it, I felt like it was exactly what I wanted to say, but couldn’t find the necessary words. Thank you!"

Customer Avatar
Ian McGregor
UK, Student

"I don’t know what I would do without your assistance! With your help, I met my deadline just in time and the work was very professional. I will be back in several days with another assignment!"

Customer Avatar
Shannon Williams
Canada, Student

"It was the perfect experience! I enjoyed working with my writer, he delivered my work on time and followed all the guidelines about the referencing and contents."

  • 5-paragraph Essay
  • Admission Essay
  • Annotated Bibliography
  • Argumentative Essay
  • Article Review
  • Assignment
  • Biography
  • Book/Movie Review
  • Business Plan
  • Case Study
  • Cause and Effect Essay
  • Classification Essay
  • Comparison Essay
  • Coursework
  • Creative Writing
  • Critical Thinking/Review
  • Deductive Essay
  • Definition Essay
  • Essay (Any Type)
  • Exploratory Essay
  • Expository Essay
  • Informal Essay
  • Literature Essay
  • Multiple Choice Question
  • Narrative Essay
  • Personal Essay
  • Persuasive Essay
  • Powerpoint Presentation
  • Reflective Writing
  • Research Essay
  • Response Essay
  • Scholarship Essay
  • Term Paper
We use cookies to provide you with the best possible experience. By using this website you are accepting the use of cookies mentioned in our Privacy Policy.