CREATE CLASS FRUIT FRUIT WITH AT LEAST THREE DATA MEMBER AND DISPLAY LEAST 5 FRUITS DETAILS
hello friends....
TAKE THE FIRST STEP TO KNOWLEDGE FRIENDS BECAUSE KNOWLEDGE IS FREE.
/* CREATE CLASS FRUIT WITH AT LEAST THREE DATA MEMBER. INITIALIZE THE CLASS MEMBERS USING CONSTRUCTOR AND DISPLAY THE DETAILS OF AT
LEAST 5 FRUITS. */
#include<iostream.h>
#include<conio.h>
class fruits
{
int price;
char name[20],color[20];
public:
void getdata();
void animation();
void display();
};
void fruits::getdata()
{
cout<<"enter fruit name :";
cin>>name;
cout<<"enter fruit color :";
cin>>color;
cout<<"enter fruit price :";
cin>>price;
}
void fruits::animation()
{
cout<<"fruit name\tfruit color\tfruit price"<<endl;
}
void fruits::display()
{
cout<<name<<"\t\t"<<color<<"\t\t"<<price<<endl;
}
void main()
{
fruits f1,f2,f3,f4,f5;
clrscr();
f1.getdata();
f2.getdata();
f3.getdata();
f4.getdata();
f5.getdata();
cout<<"\n";
f1.animation();
f1.display();
f2.display();
f3.display();
f4.display();
f5.display();
getch();
}
OUTPUT
============
enter fruit name :pear
enter fruit color :green
enter fruit price :40
enter fruit name :peach
enter fruit color :pink
enter fruit price :90
enter fruit name :apple
enter fruit color :red
enter fruit price :60
enter fruit name :banana
enter fruit color :yellow
enter fruit price :20
enter fruit name :orange
enter fruit color :orange
enter fruit price :10
fruit name fruit color fruit name
pear green 40
peach pink 90
apple red 60
banana yellow 20
orange orange 10
* * * * * * * * * * * * * *
>> IF YOU LIKE THIS BLOG, PLEASE SHARE AND SUBSCRIBE. ALSO COMMENT FOR THIS BLOG.>> IF YOU HAVE ANY QUESTIONS PLEASE ASK IN COMMENT.>> IF YOU WANT TO LEARN HTML WITH OUTPUT, SO VISIT THIS BLOGhttps://dnpwebdeveloper.blogspot.com/
>> IF YOU WANT TO LEARN C PROGRAM WITH OUTPUT, SO VISIT THIS BLOG
Comments
Post a Comment