C Program to print Multiplication by using Addition

#include<stdio.h>
main()
{
 int a,b,i,multiplication=0;
 printf("Enter a,b\n");
 scanf("%d%d",&a,&b);
 if(b<0)
 {
  a=a+b;
  b=a-b;
  a=a-b;
 }
 if(a>=0)
 {
      for(i=1;i<=a;i++)
     multiplication+=b;
 }
 if(a<0)
 {
  for(i=a;i<=-1;i++)
  multiplication-=b;
 }
 printf("Multiplication=%d\n",multiplication);
}

Post a Comment

If you have any doubts, Please let me know
Thanks!

Previous Post Next Post