Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using c++ Exercise 2: Mathematical Operations (with floating point) by the user, and then output the sum and the average of the numbers. Your Program

Using c++
image text in transcribed
Exercise 2: Mathematical Operations (with floating point) by the user, and then output the sum and the average of the numbers. Your Program Create a new file lab01_ ex2.cpp for this exercise. The program will sum sik numbers provided as input You have 6 measurements (what data type will you use to hold measurements?) from a scientific experiment, and you need the sum and the average of these measurements. Write a program to take in the six numbers from the standard input (cin) with the input operator ("), and sum them. Then divide by the number of values (6) to get the average. Output the sum and the average. Notice that even though we divided the sum (which is a floating point number) by the count (an integer), the resulting average is floating point: when you mix the two type in an arithmetic expression, floating point (the more "precise" type) "wins". Example: If your 6 numbers are 1.5, 2.1, 3.8, 4.2, 5.7, 6.1 Your output should look like this (user input is bolded and underlined): Enter six fp numbers on a single line, separated by spaces: 1.5 2.1 3.8 4.2 5.7 6.1 sum of 1.5 + 2.1 + 3.8 + 4.2 + 5.7 + 6.1 Average 3.9 23.4

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

Transact SQL Cookbook Help For Database Programmers

Authors: Ales Spetic, Jonathan Gennick

1st Edition

1565927567, 978-1565927568

More Books

Students also viewed these Databases questions

Question

What is computer neworking ?

Answered: 1 week ago