type="text/javascript">

Sabtu, 29 Maret 2014

5.7 Figure 5.12 Program to Process Bald Eagle Sightings for a Year

Program c++ nya :
 
#include <cstdlib>
#include <iostream>
#define SENTINEL 0
#define NUM_MONTHS 12

using namespace std;

int main(int argc, char *argv[])
{
    int m, mem_sight,sightings;
   
    cout<<"BALD EAGLE SIGHTINGS"<<endl;
    cout<<endl;
    for(m=1;m<=NUM_MONTHS;m++){
    sightings=0;
    cin>>mem_sight;
    while(mem_sight != SENTINEL){
                   if(mem_sight>=0)
                   sightings+= mem_sight;
                   else
                   cout<<"Warning negative count ingores"<<mem_sight<<endl;
                   }
                   cout<<"month = "<<m<<sightings;
                   }
    system("PAUSE");
    return EXIT_SUCCESS;
}


screenshot :


Tidak ada komentar:

Posting Komentar