Write a c++ program to multiply two numbers without using multiplication operator.
#include<iostream.h> #include<conio.h> void main () { int a,b,i,temp=0; clrscr(); cout<<"Enter Two numbers for multiplication"; cin>>a>>b; for(i=1;i<=b;i++) { temp=temp+a; } cout<<endl<<"Result are:: "<<temp; getch(); }
Description :
This is the one stop educational site for all Electronic and Computer students. If you want to learn something new then we are here to help. We work on Microcontroller projects, Basic Electronics, Digital electronics, Computer projects and also in basic c/c++ programs.
#Home #Sitemap #Submit #Terms of Use
Copyright©2011 electrofriends.com All Rights Reserved
Contact:info@electrofriends.com | Powered by Dhyeya
It will not work
1.If a is -ve
2.b is -ve
inefficient program
how include negative numbers?
how include negative numbers?
how include negative numbers?
THNAKS
thank u sommuch
how include negative numbers?
// Multiplication.cpp : By Mu’men Yassin (XZz_Yassin)
#include
using namespace std;
int multiplication(int a,int b){
int total=0,c;
if(a>=0){
for (int c=0;c=a+1;c–){
if(b>=0){
total-=b;
}
else{
total-=b;
total=abs(total);
}
}
}
return total;
}
int main()
{
while(true){
int x,y;
char check;
cout <>x;
cout <>y;
cout<<endl<<multiplication(x,y)<<endl;
cout<>check;
cout<<endl;
if(check=='Y' || check=='y'){
continue;
}
else{ //it's never mind if the user entered N or n or else
break;
}
}
cout << "Thnx for using my product, XZz_Yassin 2012\n";
system ("PAUSE");
return 0;
}
// Multiplication.cpp : By Mu'men Yassin (XZz_Yassin)
#include
using namespace std;
int multiplication(int a,int b){
int total=0,c;
if(a>=0){
for (int c=0;c=a+1;c--){
if(b>=0){
total-=b;
}
else{
total-=b;
total=abs(total);
}
}
}
return total;
}
int main()
{
while(true){
int x,y;
char check;
cout <>x;
cout <>y;
cout<<endl<<multiplication(x,y)<<endl;
cout<>check;
cout<<endl;
if(check=='Y' || check=='y'){
continue;
}
else{ //it's never mind if the user entered N or n or else
break;
}
}
cout << "Thnx for using my product, XZz_Yassin 2012\n";
system ("PAUSE");
return 0;
}
thanks
good