So, I tried to write a simple C program which would calculate multiplication of two numbers without using *
operator. But the result is not coming as expected. I can't understand why. This is the code:
#include<stdio.h>
int main()
{
int a=1,b=1,c=1,i;
printf("\n 1st element=");
scanf("%d",&a);
printf("\n 2nd element=");
scanf("%d",&b);
for(i=0;i<b;i++)
{
a=a+a;
}
printf("\n result=%d",a);
return 0;
}