Hello
I wrote program in c that can be find positive and negative number. after that I am trying to find out how many positive and negative number's are there in array
How to find out how many positive and negative number's are there in array
I wrote program in c that can be find positive and negative number. after that I am trying to find out how many positive and negative number's are there in array
Code:
#include <stdio.h>
int main(void)
{
int i;
int PositiveNegative[10] = {5,2,-1,4,8,-6,8,-7,9,1};
for (i = 0; i <10; i++)
{
if (PositiveNegative[i]>0)
{
printf("Positive number %d \n",PositiveNegative[i]);
}
else
{
printf("Negative number %d \n",PositiveNegative[i]);
}
}
return 0;
}
Code:
Positive number 5
Positive number 2
Negative number -1
Positive number 4
Positive number 8
Negative number -6
Positive number 8
Negative number -7
Positive number 9
Positive number 1
How to find out how many positive and negative number's are there in array