type="text/javascript">

Sabtu, 29 Maret 2014

5.6 Figure 5.10 Sentinel-Controlled while Loop

Program c++ nya :

#include <cstdlib>
#include <iostream>
#define sentinel -44

using namespace std;

int main(int argc, char *argv[])
{
    int sum=0,score;
   
    cout<<"Enter first score ( or "<<sentinel<<"to quit)>";
    cin>>score;
    while (score !=sentinel){
          sum += score;
          cout<<"enter next score("<<sentinel<<"to quit)>";
          cin>>score;
          }
          cout<<"Sum of exam score is "<<sum<<endl;
         
    system("PAUSE");
    return EXIT_SUCCESS;
}

#Screenshotnya :
 



Tidak ada komentar:

Posting Komentar