14 November 2011

A simple class program in C++ to division using classes.

#include<iostream.h>
#include<stdio.h>
#include<conio.h>
class div
{
private:
int no1,no2;
public:
void getdata()
{
cout<<"\n Enter the 1st number :";
cin>>no1;
cout<<"\n Enter the 2nd number :";
cin>>no2;
}
void putdata()
{
cout<<"\n \n The 1st number is "<<no1;
cout<<"\n \n The 2nd number is "<<no2;
}
int caldiv()
{
int div1;
if(no1>no2)
{
div1=no1/no2;
}
else
{
div1=no2/no1;
}
return(div1);
}
};
void main()
{
int num;
clrscr();
div d;
d.getdata();
d.putdata();
num=d.caldiv();
cout<<"\n \n The division of two numbers is "<<num;
getch();
}

0 comments:

Post a Comment