14 November 2011

A program using classes to get the mod.

#include<iostream.h>
#include<stdio.h>
#include<conio.h>
class mod
{
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 calmod()
{
int mod1;
mod1=no1%no2;
return(mod1);
}
};
void main()
{
int num;
clrscr();
mod m;
m.getdata();
m.putdata();
num=m.calmod();
cout<<"\n \n The modulus of two numbers is "<<num;
getch();
}

0 comments:

Post a Comment