a c++ program that multiply two integers without using multiply operator.

Discussion in 'C++' started by ahmad mohsin, Mar 13, 2010.

  1. ahmad mohsin

    ahmad mohsin New Member

    Joined:
    Mar 12, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    How far have you got and where are you stuck? Do you know how to multiply without using a multiply? (Hint: What is 10^(log a + log b), using log base 10)
     
  3. techgeek.in

    techgeek.in New Member

    Joined:
    Dec 20, 2009
    Messages:
    572
    Likes Received:
    19
    Trophy Points:
    0
    Occupation:
    EOC (exploitation of computers)..i m a Terminator.
    Location:
    Not an alien!! for sure
    Home Page:
    http://www.techgeek.in
    try this:-
    Code:
    # include<iostream.h>
    # include<math.h>
    int main()
    {
    int i,j;
    double temp1,temp2,k;
    cin>>i>>j;
    temp1=log10(i);
    temp2=log10(j);
    k=pow(10,temp1+temp2);
    cout<<k;
    }
    
    
    
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice