#include %26lt;iostream%26gt;
using namespace std;
int main()
{
int accNum, begin , charges, credits ,
limit;
cout%26lt;%26lt; "Enter account number: ";
cin%26gt;%26gt;accNum;
while (accNum !=-1)
{
cout%26lt;%26lt;"Beginning balance: ";
cin%26gt;%26gt;begin;
cout%26lt;%26lt;endl%26lt;%26lt;"Total charges: ";
cin%26gt;%26gt;charges;
cout%26lt;%26lt;endl%26lt;%26lt;"Total credits: ";
cin%26gt;%26gt;credits;
cout%26lt;%26lt;endl%26lt;%26lt;"Credit limit: ";
cin%26gt;%26gt;limit;
if (begin+charges-credits %26gt;limit){
cout%26lt;%26lt;"\t Calculating.."%26lt;%26lt;endl
%26lt;%26lt;"Account: "%26lt;%26lt;accNum;
cout%26lt;%26lt;"Credit limit: "%26lt;%26lt;limit
%26lt;%26lt;endl;
cout%26lt;%26lt;"Balace: "%26lt;%26lt;begin+charges-credits
%26lt;%26lt;endl;
cout%26lt;%26lt;"Exceeded !"%26lt;%26lt;endl;
}
cout%26lt;%26lt; "Enter account number: ";
cin%26gt;%26gt;accNum;
}
}
Why this program loop infinitely? [C++]?
There is nothing wrong with this program.
It only 'loops endlessly' when you input a non-number value.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment