Sunday, November 28, 2010

Write a program to count the number of positive and negative numbers...

#include
main()
{
int a[50];
int count_neg=0;
int count_pos=0,i,n;

printf("Enter the size of the array:");
scanf("%d",&n);
printf("Enter the elements of the array:\n");
for(i=0;i scanf("%d",&a[i]);
for(i=0;i {
if(a[i]<0)
count_neg++;
else
count_pos++;
}
printf("There are %d negative numbers in the array\n",count_neg);
printf("There are %d positive numbers in the array\n",count_pos);
}