Write a program to enter the numbers till the user wants and at the end it should display the count of positive, negative and zeros entered.

 /*z

Write a program to enter the numbers till the user wants and at the end it should display
 the count of positive, negative and zeros entered.
  */

#include <stdio.h>

int main() {
      
      int num,  positive=0negative=0zero=0;
      char d;
    
     while(1)
     {
          printf("Enter number :\n");
          scanf("%d", &num);
          if(num>0)
          positive++;
          else if(num<0)
          negative++;
          else 
          zero++;
          printf("Enter Y or y for Entering Next number :\n");
          printf("Enter N or n to exit :\n");

          // ye waala scanf input ku ni lera hai?
          scanf("%c",&d);
          if(d=='Y'||d=='y')
          ;
          else if(d=='N'||d=='n')
               break;
          else
          {
              printf("invalid response\n");
            break;
          }
          
          
     }
      
      printf("Total Postive numbers are :\t%d"positive);
       printf("Total Negative numbers are :\t%d"negative);
        printf("Total Zero numbers are :\t%d"zero);
      
      
    
    return 0;
}

Comments