In This Program samples we used c++ if method in order  toTo count only positive number the use enter using c++
algorithm
if the user entered a postive number the programs add it to the sum and increment the counter And if the user entered negative numbers the program decrement and the count and ancel the addition by subtracting the number from the sum

 

 

 

 

 

 

 

 

 

  

#include <iostream>
  using namespace std ;


  int main (){
int n , sum ;
int c[200];
sum = 0 ;
// This program allows  to calulate  the sum  of only positive numbers

cout<<" Enter the number of psotioive numbers you want to add     " ;
  cin>> n ;


  for(int i=0 ; i<n; i++){
     cout<<" Enter the number  you want to add ";

      cin>>c[i];
     sum +=c[i] ;

          if(c[i]<0){
              cout<<" \nYou entered a  negative number ";
             sum-= c[i] ;// concel the addiction

              i--; // decrement the counter to counteract the increment
    }         }


  cout <<"The sum of the  positive numbers is    "<<sum <<endl <<endl<<endl;
      return 0 ;

  }

 

there are more samples on the left