Answer to Question #293590 in C++ for daim

Question #293590

take 10 integer inputs from user and print the following:


01:postive number


02:negative number


03:odd numbers


04:even numbers all through arra

1
Expert's answer
2022-02-03T12:48:58-0500
#include <iostream>


int main()
{
    int arr[10]{};
    std::cout << "Enter 10 numbers" << std::endl;
    for (int i = 0; i != 10; ++i)
    {
        std::cin >> arr[i];
    }


    std::cout << "Positive numbers" << std::endl;
    for (int i = 0; i != 10; ++i)
    {
        if (arr[i] > 0)
        {
            std::cout << arr[i] << '\t';
        }
    }
    std::cout << "\n\nNegative numbers" << std::endl;
    for (int i = 0; i != 10; ++i)
    {
        if (arr[i] < 0)
        {
            std::cout << arr[i] << '\t';
        }
    }


    std::cout << "\n\nOdd numbers" << std::endl;
    for (int i = 0; i != 10; ++i)
    {
        if (arr[i] % 2 != 0 )
        {
            std::cout << arr[i] << '\t';
        }
    }


    std::cout << "\n\nEven numbers" << std::endl;
    for (int i = 0; i != 10; ++i)
    {
        if (arr[i] % 2 == 0)
        {
            std::cout << arr[i] << '\t';
        }
    }


    return 0;
}



Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog