Question

C++ Suppose a user is prompted to enter four floating point number values. Write a C++...

C++
Suppose a user is prompted to enter four floating point number values. Write a C++ program that outputs the number of input values, the number of negative values, and the number of even values.
0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <iostream>

using namespace std;

int main() {
    int size;
    int evens = 0, negs = 0, count = 0, num;
    for (int i = 0; i < 4; ++i) {
        cout << "Enter a number: ";
        cin >> num;
        if (num < 0)
            ++negs;
        if (num % 2 == 0)
            ++evens;
        ++count;
    }
    cout << "Number of numbers = " << count << endl;
    cout << "Number of even numbers = " << evens << endl;
    cout << "Number of negative numbers = " << negs << endl;
    return 0;
}
Add a comment
Know the answer?
Add Answer to:
C++ Suppose a user is prompted to enter four floating point number values. Write a C++...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT