c++ program to create an item with two private num int and float cost with two public functions

/*WAP to create a class item with two private variable
 number -int
 cost -float
 and two public function void getdata() and void putdata()
 */

#include<iostream>
#include<stdio.h>
using namespace std;
class item
{
int number;
float cost;
public:
void getdata();
void putdata();
};

void item::getdata()
{
cout<<"Enter the number : ";
cin>>number;
cout<<"Enter the cost";
cin>>cost;
}

void item::putdata()
{
cout<<"Number : "<<number;
cout<<endl<<"Cost : "<<cost;
}


int main()
{
item m;
m.getdata();
m.putdata();
return 0;

}
OUTPUT-

Enter the number : 9
Enter the cost65.5
Number : 9
Cost : 65.5

Comments

Popular posts from this blog

cpanel exam CPSP Answers

How to install zimbra collaboration suite 8.8.11 on CentOS 7

awstats installation