Search This Blog

Sunday, 9 March 2014

finding product of two numbers without using multiplication operator


#include<iostream.h>
#include<conio.h>

void main()
{
  int multiplicand,multiplier,i,sum;
  cout<<"Enter multiplier and multiplicand :";
  cin>>multiplier>>multiplicand;
  sum=0;
  //determining the multiplication
       int min=multiplier<=multiplicand?multiplier:multiplicand;
       int max=multiplier>multiplicand?multiplier:multiplicand;
       for(i=0;i<min;i++)
         sum+=max;
     cout<<"\nAnswer of (multiplier * multiplicand) :"<<sum;
  //ends here
  getch();
}

Output


No comments:

Popular Posts