Infolinks - Earn Easy Money

Saturday, April 4, 2015

C++ program to calculate how many numbers are positive or negative in given numbers

#include<iostream>
using namespace std;
int main()
{
  int target , p=0, n=0, num;
  cout << "Enter how many numbers you wants to enter? " ;
  cin >> target;
  for( int i = 1 ; i <= target ; i++ )
  {
cout << "Enter a number : " ;
   cin >> num ;
   if (num>0) p++ ;
   if (num<0) n++ ;
  }
  cout << "Positive numbers = " << p;
  cout << "\n Negative numbeers =" << n;
  return 0;
}

No comments:

Post a Comment

Must drop your comments about post.