so I wrote a code for multiplying numbers a =12 and b =18
Code: Select all
#include <stdio.h>
#include <string.h>
char x[] = "0012";
char y[] = "0018";
char z[7];
char r[7];
int main(void)
{
int i, j;
int temp;
memset(z, '0', 8);
memset(r, '0', 8);
for(j = 3; j >= 0; j--)
for(i = 3; i >= 0; i--)
{
temp = (x[i] - '0') * (y[j] - '0') + (r[i+j+1] - '0');
z[i+j+1] += (temp % 10);
r[i+j] += (temp / 10);
}
and I cannot see what is wrong with it as it gives the incorrect result.