Infolinks - Earn Easy Money

Saturday, April 4, 2015

C++ program to calculate how many numbers are positive or negative in given numbers (second method)

#include <iostream>
using namespace std;
int main()
{
  int n[10];
  int pos,neg;
  pos=neg=0;
 
  for ( int i = 0 ; i<6 ; i++ )
  {
  cout << "Enter integer to check" << endl ;
  cin >> n [i];
   if (n[i]>0)
   {
    pos++;
   }
   else
{
    neg++;
   }
  }
  cout << "+ve numbers are" << endl << pos ;
  cout << "\n -ve numbers are" << endl << neg;
  return 0 ;
}

No comments:

Post a Comment

Must drop your comments about post.