About

Tugas Kelompok ebook chapter 5 Alpro

 5.8 Figure 5.14  Validating Input Using do-while Statement
 #include <cstdlib>
#include <iostream>

using namespace std;

 int
 get_int (int n_min, int n_max) {
         int in_val,status,error;
         char skip_ch;

do {
    error=0;
    cout<<"Enter an integer in the range from "<<n_min<<endl;
    cout<<"to inclusive> "<<n_max;
    status = in_val;
  
    if (status != 1){
       error=1;
       cin>>skip_ch;
       cout<<"Invalid character >>"<<skip_ch;
       cout<<"Skipping rest of line."<<endl;
       }
       else if (in_val < n_min || in_val > n_max ) {
            error =1;
            cout<<"Number is not in range."<<in_val;
            }
       do
          cin>> skip_ch;
       while (skip_ch != ' ');
       }
       while (error);
     
       return (in_val);
       }

Judul : Tugas Kelompok ebook chapter 5 Alpro
Url : https://fiqriany1300018072.blogspot.com/2014/03/tugas-kelompok-ebook-chapter-5-alpro_6108.html
Pada : Senin, 24 Maret 2014
Oleh : Unknown
Respond : 0
Share :

0 komentar:

Posting Komentar

Copyright © · bikin pusing ~ Template by Jasriman Sukri