Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program 1 Write a short C++ program that prompts the user to input a double value x and then computes and prints the number of

Program 1 Write a short C++ program that prompts the user to input a double value x and then computes and prints the number of times we can divide x by 2 before we get a number less than 2.

Program 2 Write a short C++ program that prompts the user to enter an integer n, and then accepts n floating point numbers as input. Your program should then print the maximum, minimum, and average of the list of numbers. For example, if the user enters 5, followed by 3.2, 1.1, 10, 12.5, and 23, the output should be: minimum: 1.1 maximum: 23 average: 9.96

Program 3 A number n is perfect if it is equal to the sum of its proper divisors, where a proper divisor is a number which divides n and is less than n. For example, 6 is a perfect number because 1 + 2 + 3 = 6, and 1, 2, and 3 are the only divisors less than 6. Similarly, 28 is perfect also, because 1 + 2 + 4 + 7 + 14 = 28. Write a function isPerfect that takes an input n as input and returns the boolean true if n is perfect, and false otherwise. Then test your function by writing a main program that checks for all perfect numbers in the range 1 to 9999 by testing each number one at a time. When a number is found to be perfect, your program should print it to the screen. Note: The first two lines of output should be 6 and 28, and your program should find two other perfect numbers as well.

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

Big Data With Hadoop MapReduce A Classroom Approach

Authors: Rathinaraja Jeyaraj ,Ganeshkumar Pugalendhi ,Anand Paul

1st Edition

1774634848, 978-1774634844

More Books

Students also viewed these Databases questions