Practical No 4S OOP
Practical No 4S OOP
#include<iostream.h> #include<iostream.h>
#include<conio.h> #include<conio.h>
class circle class student
{ { public:
float b,h,a; int rollno;
public: char name[10],branch[10],grade; void
void read() read()
{ {
cout<<"Enter the base and height:"; cout<<"Enter roll no:"; cin>>rollno;
cin>>b>>h; cout<<"Enter the name:";
} cin>>name;
void compute() cout<<"Enter the branch:";
{ cin>>branch;
a=0.5*b*h; cout<<"Enter the grade:";
} cin>>grade;
void display() }
{ void display()
cout<<"Area of Triangle="<<a; {
} cout<<"\n\t \t Student Details\n"<<endl;
}; cout<<"Roll No\t \t Name \t \t Branch\t
void main() \t Grade"<<endl;
{ clrscr(); cout<<"\n------------------------\n"
triangle t; cout<<rollno<<"\t \t"<<name<<"\t
t.read(); \t"<<branch<<"\t
t.compute(); \t"<<grade<<endl;
t.display(); }
getch(); };
} void main()
{
student s; s.read();
OUTPUT:- s.display();
getch();
Enter the base and height: 3 }
4
Area of triangle=6 OUTPUT:
Enter roll no:10
Enter the name:Siddhesh
Enter the branch:SYIF
Enter the grade:A
Student Details
Roll No Name Branch Grade
10 Siddhesh SYIF A