Practical 10
#include<iostream>
using namesapce std;
class ITEM
{
int number;
float cost;
void setdata(int,float);
void getdata();
void putdata();
};
void ITEM :: setdata(int i,float j)
{
number=i;
cost=j;
}
void ITEM :: getdata()
{
int i; float j;
cout<<"Enter number";
cin>>i;
cout<<"\nEnter cost";
cin>>j;
}
void ITEM :: putdata()
{
cout<<"Number is :"<<number;
cout<<"Cost is :"<<cost;
}
int main()
{
ITEM i;
i.getdata();
i.putdata();
i.setdata(12,15.16);
i.putdata();
}
output:
enter number : 2
enter cost : 1.5
number is 2
cost is 1.5
number is 12
cost is 15.16
output:
enter number : 2
enter cost : 1.5
number is 2
cost is 1.5
number is 12
cost is 15.16
No comments:
Post a Comment