Wednesday, October 19, 2011

this is th draft for 4.1 programming exercise chapter 4. maybe need some improvement,

#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;
   
    while ( num !=0)
    {
          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: