Monday, August 5, 2013

Program to enter the numbers till the user wants and at the end it should display the count of positive negative and zeros entered : Logic building(5)



      int inputNum;
      int positive = 0;
      int negative = 0;
      int Zero=0;
      int choice;

      do
      {
      printf("\nEnter the number ");
      scanf("%d",&inputNum);
     

      inputNum >= 0 ? (inputNum == 0 ? (Zero +=1) :(positive += 1)) : (negative +=1);

      printf("\nDo you want to enter more number(1/0) : ");
      scanf("%d",&choice);

      }
      while(choice==1);


      printf("\nPositive Number(s): %d \nNegative Number(s): %d \nZero(s): %d ",positive,negative,Zero);


       

2 comments: