Home Basic Loop Array string Function Pointer Contact STUDY

# AHF    C    PROGRAM    SOLVING

### Count positive, negative and zero untill (-1) is encountered

```
// AHF C PROGRAM SOLVING

//solving here ITERATIVES STATEMENTS type of programming problem

#include<stdio.h>
#include<math.h>
#define pf printf

int main()
{
int number;

int positive= 0,negative= 0,zero= 0,count=0;

pf("\nEnter any number. Enter -1 to exit........\t: ");
scanf("%d",&number);    //this input will start the loop

while(number!=-1)   //ending condition of loop
{
if(number>0)
positive++;
else if(number&lg0)
negative++;
else
zero++;

count++;    //counting for total given input

pf("\nEnter any number. Enter -1 to exit........\t: ");
scanf("%d",&number);    //this input will stop the loop
}

//printing the required statement
pf("\n\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\");

pf("\n\nCount of positive number= %d",positive);

pf("\nCount of negative number= %d",negative);

pf("\ncount of zero= %d",zero);

pf("\nTotal given input= %d",count);

return 0;
}

```
OUTPUT: