Regarding do while loops

Talk about anything here...

Moderators: Darobat, RecursiveS, Dante Shamest, Bugdude, Wizard

Regarding do while loops

Postby ballurohit » Sat Apr 28, 2012 7:29 am

Here I got compiling error while running the program. The program is as follows:

#include <iostream.h>
#include <conio.h>
class account
{
private:
int balance, c,d;
public:
account(int x)
{
if (x>=0)
{
balance=x;
}
else {
cout<<"Invalid entry\n your account balance has been set to 0\n";
balance =0;
}
}
void credit()
{
cout<<"Enter the amount you want to deposit:\n";
cin>>c;
balance=balance+c;
cout<<"You deposited.\n";
}
void debit()
{
cout <<"Enter the amount you want to draw:\n";
cin>>d;
balance=balance-d;
cout <<"You have withdrawn.\n";
}
void get_balance()
{
cout <<"Your Current Balance is:"<<balance<<endl;
}
};
void main()
{
int g,h,k,j;
char a;
clrscr();
cout<<"To create an Account-Account-1-Press a\n";
do
{
cin>>a;
if(a=='a')
{
cout <<"Enter the initial balance you want to deposit:\n";
cin>>g;
account (g);
}
else
{
cout<<"Invalid entry. Enter 'a' again\n";
}
}while (a!='a');
account one(g);
cout<<"To create an Account-Account 2- Press a\n";
do
{
cin>>a;
if(a=='a')
{
cout <<"Enter the initial balance you want to deposit\n";
cin>>h;
a2:;
account(h);
}
else
{
cout <<"Invalid entry.Enter 'a' again\n";
}
}while (a!='a');
cout <<"For deposit, withdrawal or balance inquiry of Account 1 Press 1, For account two Press 2.\n";
cin>>k;
switch(k)
{
case 1:
cout<<"For deposit Press 1\n For withdrawal Press 2\n For Balance Inquiry Press 3\n To go to the other account
<<Press 4\n To exit Press 5\n;
do
{
cin>>j;
switch(j)
{
case 1:
one.credit();
break;
case 2:
one.debit();
break;
case 3:
one.get_balance();
break;
case 4:
goto a2:;
case 5:
break;
default:
cout << "Not a number between 1 and 5!\n";
break;
}
return 0;
}


};
N.B: I am getting compiling error " functions containing do are not expanded inline"
Last edited by ballurohit on Sun Apr 29, 2012 1:14 am, edited 4 times in total.
ballurohit
 
Posts: 9
Joined: Thu Mar 29, 2012 10:59 am

Re: Regarding do while loops

Postby ballurohit » Sat Apr 28, 2012 7:31 am

Kindly send me reply by Email ID which is"ballubhainarsinhbhai@gmail.com"
Thanks in advance.
(b.n.rohit)
ballurohit
 
Posts: 9
Joined: Thu Mar 29, 2012 10:59 am

Re: Regarding do while loops

Postby exomo » Sun Apr 29, 2012 11:21 am

ballurohit wrote:Kindly send me reply by Email ID which is"ballubhainarsinhbhai@gmail.com"
Thanks in advance.
(b.n.rohit)

Sorry, I don't see why I should reply be mail. I will just answer here and hope you read it anyway.

Code: Select all
case 1:
cout<<"For deposit Press 1\n For withdrawal Press 2\n For Balance Inquiry Press 3\n To go to the other account
<<Press 4\n To exit Press 5\n;

some " missing. Change to:
Code: Select all
case 1:
cout<<"For deposit Press 1\n For withdrawal Press 2\n For Balance Inquiry Press 3\n To go to the other account"
<< "Press 4\n To exit Press 5\n";


use an up-to-date compiler. iostream.h doesn't exist any more, it is called just iostream now. all the iostream stuff is in the namespace std. main() should return int.
Who needs a signature anyway.
User avatar
exomo
 
Posts: 867
Joined: Fri Sep 26, 2003 12:30 pm
Location: germany->baden

Re: Regarding do while loops

Postby ballurohit » Mon Apr 30, 2012 11:25 pm

" Quote I just compile it after solving the problem of compiler. But many many thanks for your valuable advice/instructions. Unquote"
ballurohit
 
Posts: 9
Joined: Thu Mar 29, 2012 10:59 am


Return to Open Discussion

Who is online

Users browsing this forum: No registered users and 3 guests

cron