Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please answer Q3 and Q4 Reference for part b 3. In one or two sentences, explain why the value printed by the program in response

image text in transcribed

Please answer Q3 and Q4

Reference for part b

image text in transcribed

3. In one or two sentences, explain why the value printed by the program in response to the samples given in part (b) does not match the value that a human might expect. Use line numbers for specificity. 4. In one or two sentences, suggest a change to the program to make the calculation of the average more accurate. average.c #include 1 2 3 4 5 int main() { int i; int sample; int average = 0; 6 7 9 10 11 12 13 for (i = 1; 10 >= i; i = i + 1) { /* Read a sample. */ printf ("Enter sample #%d: ", i); if (1 != scanf ("%d", &sample)) { printf ("Numeric samples only! "); /* Quit indicating failure (anything non-zero, * by convention). return 3; } 14 15 */ 16 17 18 19 /* Process the next sample. */ average = average + (sample / 10); 20 21 } 22 23 /* Print the results. */ printf ("The average is %d. ", average); 24 25 26 27 /* Program has finished successfully, * * so return by convention. */ return; 28 29 } Enter sample #1: 19 Enter sample #2: 19 Enter sample #3: 19 Enter sample #4: 19 Enter sample #5: 19 Enter sample #6: 19 Enter sample #7: 19 Enter sample #8: 19 Enter sample #9: 19 Enter sample #10: 19 The average is 10

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Intelligent Information And Database Systems 6th Asian Conference Aciids 2014 Bangkok Thailand April 7 9 2014 Proceedings Part I 9 2014 Proceedings Part 1 Lnai 8397

Authors: Ngoc-Thanh Nguyen ,Boonwat Attachoo ,Bogdan Trawinski ,Kulwadee Somboonviwat

2014th Edition

3319054759, 978-3319054759

More Books

Students also viewed these Databases questions