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

Leave a Comment

Your email address will not be published. Required fields are marked *

Hire a server Expert to resolve the issue Now.

Hire a server Expert to resolve the issue Now.

Resolve this issue in just 5$ from https://serverexpert.io

 

You have Successfully Subscribed!

Open chat