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

Cannot take in the decimal numbers through a keyboard, has to be like: Void main

ID: 3726801 • Letter: C

Question


Cannot take in the decimal numbers through a keyboard, has to be like:
Void main(void) { Int16 x = 0x4000; // is .5 in q15 And then you put in the rest and then do math i think 10. (10 Points) Write a complete C language program that uses O15 arithmetic to compute the sum of the decimal numbers -1.0,-0.5, 0.5, and 0.5, and prints out the result as a floating point number (that is the program will print out "Sum--0.5" assuming that it computes the correct value). a. b. What string would your program print out? Explain your answer

Explanation / Answer

CODE:

int main()

{

int i; // Declare integer number i this is implementing for loop

float sum=0.0,num; // Declare and initialize float values of sum=0.0 and num

printf(" Enter 4 decimal numbers: ");

for(i=1;i<=4;i++) // Create for loop terminate until 4 float values

{

scanf("%f",&num); // reading float values

sum+=num; // calculate sum of float values

}

printf(" Sum= %.1f",sum); // display sum of float values with single decimal value using "%.1f"

return 0;

}

answer:

Enter 4 numbers:

-1.0

-0.5

0.5

0.5

Sum= -0.5

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