Popular Posts

21.Write a program and show number and cost .

21.Write a program and show number and cost .

#include
#include
class item
{
int number;
float cost;
public:
void getdata(int a,float b);
void putdata(void)
{
cout<<"Number: "< cout<<"Cost: "< }
};
void item::getdata(int a,float b)
{
number=a;
cost=b;
}
int main()
{
clrscr();
item x;
cout<<"\nObject x\n\n";
x.getdata(100,299.95);
x.putdata();
item y;
cout<<"\nObject y\n\n";
y.getdata(200,175.50);
y.putdata();
getch();
return 0;
}

Output:


Object x

Number: 100
Cost: 299.95

Object y

Number: 200
Cost: 175.5

Output:
sum= 25
I= 11

No comments: