Solution 1 to 6
Solution 4

Count of Positive, Negative, and Zero Numbers

This program counts the number of positive, negative, and zero numbers from a user-provided set of integers. It prompts the user to enter a specified number of integers and then classifies each integer into one of three categories: positive, negative, or zero. The program finally displays the counts of each category.

Code Breakdown

Algorithm

  1. Start
  2. Input Limit: Read the value of n (number of integers) from the user.
  3. Initialize Counters:
    • Set pc, nc, and zc to 0 for counting positives, negatives, and zeroes, respectively.
  4. Read Integers:
    • Loop n times to read integers from the user.
    • For each integer x:
      • If x is positive, increment pc.
      • If x is negative, increment nc.
      • If x is zero, increment zc.
  5. Display Results:
    • Print the counts of positive, negative, and zero numbers.
  6. End

Code Explanation

Example Flowchart

                                    Start
                                      |
                                      V
                                Input limit n
                                      |
                                      V
                          Initialize pc, nc, zc to 0
                                      |
                                      V
                               For i = 0 to n-1
                                      |
                                      V
                                Read integer x
                                      |
                                      V
                                  Is x > 0?     
                                 /        \     
                                /          \     
                               /            \     
                              /              \     
                             /                \     
                            /                  \     
                           /                    \    
                         Yes                    No    
                        /                         \    
                       /                           \   
                      V                             V   
                 Increment pc                    Is x < 0?  
                    |                            /       \    
                    |                          Yes       No  
                    |                          /           \  
                    |                         V             V  
                    |                   Increment nc    Increment zc  
                    V                         |              |    
                    |                         V              V    
                    |                        End            End    
                    |                   
                    V                   
                   End