The Aristocats - Marie

animasi

TUGAS KELOMPOK (EBOOK CHAPTER 5 Problem Solving and Program Design in C)

Minggu, 23 Maret 2014

  • 5.7 Figure 5.12  Program to Process Bald Eagle Sightings for a Year
#include <cstdlib>
#include <iostream>
#define SENTINEL 0
#define NUM_MONTHS 12


using namespace std;

int main(void)
{
    int month,mem_sight,sightings;
   
    cout<<"BALD EAGLE SIGHTINGS"<<endl;
    for(month=1;month<=NUM_MONTHS;month++){
        sightings=0;
        cin>>mem_sight;
    while (mem_sight != SENTINEL){
          if(mem_sight>=0)
             sightings += mem_sight;
          else
          cout<<"Warning, negative count ignored"<<mem_sight<<endl;
          cin>>mem_sight;
          }
         
          cout<<"month  :  "<<month<<sightings;
          }
         
    system("PAUSE");
    return EXIT_SUCCESS;
}

0 komentar:

Posting Komentar