Write a program to declare a class "account' having data members as accountno and balance. Accept this data for 5 accounts and display the data of the accounts having balance greater than 2000
Answers
Answer:
x
Write A C++ Program To Declare A Class ‘Account’ With Data Members As Accno, Name And Bal. Accept Data For Eight Accounts And Display Details Of Accounts Having Balance Less Than 10,000.
Play
Object-Oriented-Programming-With-C
Write a C++ program to declare a class ‘Account’ with data members as accno, name and bal. Accept data for eight accounts and display details of accounts having balance less than 10,000.
Share
asked Apr 18 by anonymous
Show MoreAsk Question
1 Answer
Answer :
#include<iostream.h>
#include<conio.h>
class Account
{
long int accno, bal;
char name[10];
public:
void getdata()
{
cout<<"\nEnter account number, balance and name ";
cin>>accno>>bal>>name;
}
void putdata()
{
if(bal>10000)
{
cout<<"\nThe Account Number is "<<accno;
cout<<"\nThe Balance is "<<bal;
cout<<"\nThe Name is "<<name;
}
}
};
void main()
{
Account a[8];
int i;
clrscr();
for(i=0;i<8;i++)
{
a[i].getdata();
}
for(i=0;i<8;i++)
{
a[i].putdata();
}
getch();
}
Answer:
Write a program in c++ to declare a class account having data member as acc_no and balance. accept this data for 10 accounts and display acc_no of accounts having balance greater than 10000.