Question: 1- Correct the syntax errors in the following program, and rewrite the program so that it follows the proper style conventions. What does the program
1- Correct the syntax errors in the following program, and rewrite the program so that it follows the proper style conventions. What does the program do? (Write it out as a comment). (10 pts)
#include
int
main() {/*
* Calculate and display the difference of two values
*)
int X, /* first input value */ x, /* second
input value */
sum; /* sum of inputs */
X=9,
x=7.5
X + x = sum;
printf("%d + %d = %d "; X; x; sum); return (0);}
2- In the same main function as above, and right below the first question, before the return (0); statement, write another program that calculates the average of 3 numbers. (10 pts )
a) This program takes 3 numbers of type int as input. Declare and initialize the integer variables with your choice of names and values.
b) Declare another variable of type double to store the average of three numbers into.
c) Calculate the average of the 3 input variables and store them in the variable that you declared as type double.
d) Make sure that your average value calculations are accurate! (Hint: Use type casting)
e) Use printf to display all 3 values and their average. Your output should look similar to this:
The average of three values 2, 2 and 3 is 2.333333.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
