Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

All instructions are given in the form of comments in the file. Correct the errors and identify which error type they are. Please read all

All instructions are given in the form of comments in the file. Correct the errors and identify which error type they are. Please read all instructions very carefully. PROGRAM: #include // Before starting this assignment, please compile and run this program. // You will first notice that the program will not compile. Fix the errors and define the error types. // Next, you will notice that the program is printing incorrect information. Fix the errors and define those error types. void main() { // Problem 1: (5 points) // The statement below should cause the program to not compile. Correct the error(s). (2.5 points). n1 = 50.45; printf("Number n1 is equal to %d ", n1); // Define what type of error this is, your answer should replace the space next to "Error Type: " below (2.5 points). // Your answer should be either Syntactic, Semantic, or Contextual. printf("Error Type: ________ "); // Problem 2: (5 points) // Half of 5 is 2.5, why is the program printing 2? Correct the error(s) (2.5 points). float x = 5/2; printf("x is %f ", x); // Define what type of error this is, your answer should replace the space next to "Error Type: " below (2.5 points). // Your answer should be either Syntactic, Semantic, or Contextual. printf("Error Type: ________ "); // Problem 3: (5 points) // variable x has been initialized to 10, why does the program seem to think otherwise? Why is the program printing more statements than necessary ? Correct the error(s) (2.5 points). x = 10; if (x = 20) printf("x is equal to %0.0f. ", x); printf(" So x is equal to 20. "); if (x > 15) printf("x is equal to %0.0f. ", x); printf("So x is greater than 15. "); if (x < 20) printf("x is equal to %0.0f. ", x); printf("So x is less than 15. "); // Define what type of error this is, your answer should replace the space next to "Error Type: " below (2.5 points). // Your answer should be either Syntactic, Semantic, or Contextual. printf("Error Type: ________ "); // Problem 4: (5 points) // Surely, 10 is an even number. Why is the program printing that 10 is an odd number? Correct the error(s) (2.5 points). int p = 10; if (p / 2 == 0) printf("%d is an even number. ", p); if (p / 2 != 0) printf("%d is an odd number. ", p); // Define what type of error this is, your answer should replace the space next to "Error Type: " below (2.5 points). // Your answer should be either Syntactic, Semantic, or Contextual. printf("Error Type: ________ "); // Problem 5: (5 points) // This bit of code is meant to print "Hello, my name is John. I am 20 years old". Correct the printf statement. (2.5 points). char years = 20; // Do not change this line of code printf("Hello, my name is %c. I am %c years old ", "John", years); // Define what type of error this is, your answer should replace the space next to "Error Type: " below (2.5 points). // Your answer should be either Syntactic, Semantic, or Contextual. printf("Error Type: ________ "); } 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

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

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions