This is a sample program to output details of a box using classes.
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
class box
{
private:
int code;
char mat[10];
char col[10];
float price;
public:
void read();
void print();
};
void box::read()
{
cout<<"Enter Code, Material, Colour & Price";
cin>>code;
gets(mat);
gets(col);
cin>>price;
}
void box::print()
{
cout<<"Code Of Box Is "<<code<<'\n'<<"Colour Is "<<col<<'\n'<<"Material Is "<<mat<<'\n'<<"Price Is "<<price;
}
void main()
{
clrscr();
box b;
b.read();
b.print();
getch();
}
OUTPUT:
Enter Code, Material, Colour & Price
1128
Cloth
Blue
35
Code Of Box Is 1128
Colour Is Blue
Material Is Cloth
Price Is 35
Comments
Post a Comment
Please share your opinions and suggestions or your experience in the comments section. This way we can all help each other...
Experienced guys can share their resumes at admin@interview-made-easy.com