C Program to Count Occurrence of Positive, Zero and Negative Numbers



#include<stdio.h>
#include<conio.h>
void main()
{
    clrscr();
    int countpos=0, countneg=0, countzero=0, arr[10], i;
    printf("Enter 10 numbers : ");
    for(i=0; i<10; i++)
    {
        scanf("%d",&arr[i]);
    }
    for(i=0; i<10; i++)
    {
        if(arr[i]<0)
        {
            countneg++;
        }
        else if(arr[i]==0)
        {
            countzero++;
        }
        else
        {
            countpos++;
        }
    }
    printf("Positive Numbers = %d\n",countpos);
    printf("Negative Numbers = %d\n",countneg);
    printf("Zero = %d",countzero);
    getch();
}

Run 1:
        
Run 2:








No comments:

Post a Comment

100 C Programs with Code and Output

Program 1: C Program To Read Two Numbers And Print The Sum Of Given Two Numbers. Program 2: C Program To Read Three Numbers And Prin...