Code In Tech - The Ultimate World of Computer Technology

Saturday, 24 March 2012

C program to Find total positive and negative numbers out of less than 100 no using array

SOURCE CODE:
void main()
{
 int a[100],p=0,n=0,ne=0,z=0,i;
 clrscr();
 printf("Enter less than 100 no.");
 scanf("%d",&n);
 printf("enter diffrent %d no.",n);
 for(i=0;i<n;i++)
 {
  scanf("%d",&a[i]);

  if(a[i]==-999)
  {
   break;
  }
  if(a[i]>0)
  {
   p++;
  }
  else if(a[i]<0)
  {
   ne++;
  }
  else
  {
   z++;
  }
 }
 printf("\nTotal Positive Numbers are %d",p);
 printf("\nTotal Negative Numbers are %d",ne);
 printf("\nTotal Zero are %d",z);
 getch();
}

No comments :

Post a Comment