Program to count Number of the Positive and negative number in a 1-D integer Array. Means you have to count a positive and negative number in an Array
Logic:-
For this problem simple fact you have to know that if the number is greater than zero then the number is positive if the number is less than the number is negative otherwise the number is zero. So for this problem, we have two variable one for positive number and another for the negative number and as I said above we compare the number with zero or if the number is greater than zero we will increase the positive variable by one for negative increase negative variable by one.
Output:
Enter The Size of An Array :
5
Enter The Element :
12
32
-56
0
-4
Elment in Array is Given Below
Positive No. is = 2
Negative No. is = 2
Total Zero in array is = 1
need an explanation for this answer? contact us directly to get an explanation for this answer