Selasa, 25 Maret 2014

Ebooks Chapter 5 PROBLEM SOLVING AND PROGRAM DESIGN IN C

Diposting oleh Unknown di 09.45
5.6 Figure 5.10 Sentinel-controlled while Loop

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

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 scores is "<<sum<<endl;
   
    system("PAUSE");
    return EXIT_SUCCESS;
}


c++ :


0 komentar:

Posting Komentar

 

Rizka Site Copyright © 2012 Design by Antonia Sundrani Vinte e poucos