COUNT NUMBERS ARE GREATER AND LESS THAN ZERO, USING ARRAY

/*PROGRAM TO COUNT HOW MANY NUMBERS ARE GREATER THAN ZERO, LESS THAN ZERO, EQUAL TO ZERO USING ARRAY*/
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,eq=0,gr=0,less=0,a[10];
clrscr();
printf(“Enter the size of array: “);
scanf(“%d”,&n);
printf(“Enter %d elements in the array:\n”,n);
for(i=0;i<n;i++)
scanf(“%d”,&a[i]);
printf(“Elements in the array are:\n”);
for(i=0;i<n;i++)
printf(“%5d”,a[i]);
for(i=0;i<n;i++)
{
if(a[i]>0)
gr++;
else if(a[i]<0)
less++;
else
eq++;
}
printf(“\nTotal elements in the array are: %d\n”,n);
printf(“Elements greater than zero are: %d\n”,gr);
printf(“Elements less than zero are: %d\n”,less);
printf(“Elements equal to zero are: %d\n”,eq);
getch();
}

Leave a Reply

Your email address will not be published. Required fields are marked *