0
635views
Write a c program for multiplication using add shift method
1 Answer
written 2.9 years ago by | • modified 2.9 years ago |
C Program for Multiplication using shift add method is : -
//importing library
#include<stdio.h>
int main(){
int a, b, c;
printf("Enter an integer: \n");
scanf("%d", &a);
printf("Enter an integer: \n");
scanf("%d", &b);
//multiply(a, b);
c = 0; //product
while(b != 0)
{
if(b & '\x01' == 1)
{
c = c + a;
}
a = a << 1;
b = b >> 1;
}
printf("The product is %d", c);
return 0;
}
//Enjoy Coding.....