Wednesday, October 19, 2011

updated. 4.1

#include
#include
using namespace std;

int main()
{
    int num,negativeCounter=0,positiveCounter=0,total=0,average = 0;
   
    cout<<"Enter an integer value,the program exits if the input is 0: "<
    cin>>num;

    int sum = 0 ;
      
    while ( num !=0)
    {
   
          sum += num ;
          if (num<0)
             negativeCounter++;
         
          else if (num>0)
               positiveCounter++;
              
          else
               cout<<" "<
         
          total=total+num;
          average=static_cast(total)/(positiveCounter+negativeCounter);
          cin>>num;
         
    }
              
          cout<<" The number of positives is "<<
          cout<<" The number of negatives is "<<
          cout<<" The total is: "<<
          cout<<" The average is : "<<
              
          system ("pause");
          return 0;
              
}

.: Syukran, moga sama2 menambah ilmu =] :.

0 kalam anda: