Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Exercise #2: Simple usage of repetition (while) loops with if statements Write a program that reads in a number of integers from the keyboard.

image text in transcribedC++
Exercise #2: Simple usage of repetition (while) loops with if statements Write a program that reads in a number of integers from the keyboard. The program squares the number if it is even, takes its square root if it is odd, and does nothing if it is zero. The program prints the square of the number, the square root of the number, or nothing. The program counts the number of even numbers, the number of odd numbers, and the number of zeros. The program stops reading numbers when it reads in a negative number. After the program encounters a negative number, it prints out the number of even numbers, the number of odd numbers, and the number of zeros followed by the message "Done." on a new line Sample input/ output: Input integers, one at a time. To stop enter a negative number: 34 1156 Input integers, one at a time. To stop enter a negative number: 77 8.77496 Input integers, one at a time. To stop enter a negative number: 9 Input integers, one at a time. To stop enter a negative number: 13 3.60555 Input integers, one at a time. To stop enter a negative number: 18 324 Input integers, one at a time. To stop enter a negative number: e Input integers, one at a time. To stop enter a negative number: 44 Input integers, one at a time. To stop enter a negative number: e 936 nput integers, one at a time. To stop enter a negative number: -3 The number of positive numbers is: The number of negative numbers is: 3 The number of zeros is: 2 ne

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

Database Processing Fundamentals Design And Implementation

Authors: David M. Kroenke

5th Edition

B000CSIH5A, 978-0023668814

More Books

Students also viewed these Databases questions