Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 4. Write a C program that sums a sequence of numbers, integer or float (double). Assume that the first input is an integer number

Problem 4.

Write a C program that sums a sequence of numbers, integer or float (double). Assume that the first input is an integer number the specifies the number of values remaining to be entered. Your program should read only one value each time scanf is executed. A typical input sequence and its corresponding output might be:

Input: 5 12 1943 48.23 16 -73

Output: 1946.23

From the above input, 5 indicates that the subsequent five values are to be summed.

Problem 5.

Write a C program that calculates and prints the average of several integers. Assume the last value read with scanf is the sentinel 9999. A typical input sequence might be:

Input: 410 83 51 -9 13 9999

Output: 109.6

From the above input, 9999 indicates the sentinel value and therefore output is the average of the five integers entered by the user before that sentinel value.

Problem 6.

The factorial of a positive integer n (written as n!) is equal to the product of the positive integers from 1 to n. For instance, 3! = 3 * 2 * 1 = 6. Write a C program that evaluates the factorials of the integers from 1 to 10. Print the results like the following format:

1! = 1

2! = 2

3! = 6

4! = 24

Change the range of the numbers to be able to compute the factorials of the numbers from 15 to 20 and explain what difficulty might prevent you from calculating the factorial of numbers like 20?

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

Inductive Databases And Constraint Based Data Mining

Authors: Saso Dzeroski ,Bart Goethals ,Pance Panov

2010th Edition

1489982175, 978-1489982179

More Books

Students also viewed these Databases questions