Multiply two numbers without stric operator
#include<iostream.h>
#include<conio.h>
class mult
{
private:
int x,y,temp;
public:
void input();
void rule();
void display();
};
void mult::input()
{
cout<<" Enter the value of x:";
cin>>x;
cout<<"\n enter the value of y:";
cin>>y;
}
void mult::rule()
{
temp=0;
for(int i=1;i<=y;i++)
{
temp=temp+x;
}}
void mult::display()
{
cout<<"result="<<temp;
}
int main()
{
mult m;
clrscr();
m.input();
m.rule();
m.display();
getch();
return 0;
}
#include<conio.h>
class mult
{
private:
int x,y,temp;
public:
void input();
void rule();
void display();
};
void mult::input()
{
cout<<" Enter the value of x:";
cin>>x;
cout<<"\n enter the value of y:";
cin>>y;
}
void mult::rule()
{
temp=0;
for(int i=1;i<=y;i++)
{
temp=temp+x;
}}
void mult::display()
{
cout<<"result="<<temp;
}
int main()
{
mult m;
clrscr();
m.input();
m.rule();
m.display();
getch();
return 0;
}
Comments
Post a Comment