Program to Count Negative & Positive elements in an Array

#include<stdio.h>
#include<conio.h>
void main()
{
int x[5],i,neg=0,pos=0;
clrscr();
  for(i=0;i<5;i++)
  {
  printf("\nEnter No ");
  scanf("%d",&x[i]);
  }
  for (i=0;i<5;i++)
  {
  printf("\n\tx[%d]==%d",i,x[i]);
     if(x[i]>0)
     pos=pos++;
     else
     neg=neg++;
  }
  printf("\n\nTotal Positive %d",pos);
  printf("\n\nTotal Negative %d",neg);

getch();
}

Leave a Reply