C++ program to multiply two numbers without using multiplication operator

Share on FacebookTweet about this on TwitterDigg thisPin on PinterestShare on LinkedInShare on StumbleUponShare on TumblrShare on Google+Email this to someone

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();
}

Share on FacebookTweet about this on TwitterDigg thisPin on PinterestShare on LinkedInShare on StumbleUponShare on TumblrShare on Google+Email this to someone

18 Responses to “C++ program to multiply two numbers without using multiplication operator”

  1. XZz_Yassin

    // 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;
    }

    Reply
  2. XZz_Yassin

    // 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;
    }

    Reply
  3. #include
    #include
    {
    clrscr();
    int a,b,c;
    cout<>a>>b;
    c=a*b;
    cout<<"The answer is: "<<c;
    getch();
    }

    Reply
  4. Adesh suryan

    Hi,
    just update the For loop condition
    #include
    #include
    void main ()
    {
    int a,b,i,temp=0;
    clrscr();
    cout<>a>>b;
    for(i=1;i<b;i++)
    {
    temp=temp+a;
    }
    cout<<endl<<"Result are:: "<<temp;
    getch();
    }

    Reply
  5. periyasamy

    also
    for(i=0;i<=a;i+)
    {
    for(j=0;j<=b;j++)
    {
    count++;
    }
    }
    printf("%d",count);

    Reply

Leave a Reply