Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Could you explain to me the miskates that they\'ve already found and how did we

ID: 3789375 • Letter: C

Question


Could you explain to me the miskates that they've already found and how did we know that they are mistakes ? Thanks Part 2 (25 points In this part, you are given fragments of C programs that contain errors. For each fragment, show and explain the errors, and then rewrite the statements to fix the problem. 1) 12 points printf ("Hello world!Wn float total-grades e155, average grade total grades 4 average grade; RETURN ei Solution: the errors are highlighted in red printf ("Hello wor ld Win") semantic error: replace Wn with n float total grades e155, average grade syntax error: remove the 0 in 0155 total grades 4 average grade syntax error: average grade should be on the left side of he assignment statement RETURN 0 syntax error replace RETURN with return 2) &points; define STR "Please enter your first name and age." int main(void) alice'; short age 23 char name printf (STR); scan is name); return e; Solution the errors are highlighted in red short age 23; char name alice'; syntax error: char namel "alice"; scan ("xs xf name); semantic error: scanf("Tis thd', name sage) 3) 5points int i 18e: int x-1; while (i>e) x xii i-i 1 printf ("x- xd, ir din", x, i) Solution: semantic error: infinite while loop. The simplest way to fix this error isto replace i 1 with iri-1.

Explanation / Answer

1. is used to print a new line character which when used as gives error treating given extra as an escape sequence.

The second one must not give an error but anyway using a 0 as prefix makes no sense.

Always the LHS will be assigned the value computed by the RHS expression. So, you will see error if you try to assign or compute values in reverse order.

return is a keyword and is case sensitive. So errors occur if not taken care.

2. name must be an array with size one greater than the string which is to be assigned. The assigned string must be in double quotes only.

scanf() requires the number of format strings to be equal to the number of addresses in which the scanned variable must be stored. If the number doesn't match you will get errors.

3. The condition will never be false if the value of I is incremental. So decremented values of i will end the while loop at some iteration. Else the loop is infinite.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote