Count positive, negative & zero numbers - C++

Q. Write a C++ program to count the number of positive number, negative number and zero from the set of given numbers entered by the user.

Answer:

Following program is displaying the counts of positive number, negative number and zero from the set of given numbers entered by the user.

#include<iostream>
using namespace std;
int main()
{
        int cntp=0, cntn=0, cntz=0, arr[10], i;
        cout<<"\n Enter 10 numbers : \n";
        for(i=0; i<10; i++)
        {
                cin>>arr[i];
        }
        for(i=0; i<10; i++)
        {
                if(arr[i]<0)
                {
                        cntn++;
                }
                else if(arr[i]==0)
                {
                        cntz++;
                }
                else
                {
                        cntp++;
                }
        }
        cout<<"\n Positive Numbers : "<<cntp<<"\n";
        cout<<"\n Negative Numbers : "<<cntn<<"\n";
        cout<<"\n Zero : "<<cntz<<"\n";

        return 0;
}


Output:

count positive negative