Need help in writing this multiplication code

62 views Asked by At

I need to show process of multiplication in output.for ex:- inputs are two numbers(say 325 and 4405) the output would be:-

    325
  *4405
  -----
   1625
     0
 1300
1300
-------
1431625

NOTE:-number of spaces should be minimum.

I don't need the exact code. Just tell me which property or way I should be using to get the SPACE right in each line.or how should i proceed to get output.

1

There are 1 answers

1
ryyker On BEST ANSWER

Here is a simple example of how to make constant length printouts using printf:

int main(void)
{

    char a[6][7]={"1","22","333","4444","55555","666666"};
    int i;
    int value;

    for(i=0;i<sizeof(a)/sizeof(a[0]);i++)
    {
        value = atoi(a[i]);
        printf("%07d\n", value); //with leading zeros
        printf("% 7d\n", value); //with spaces
    }

    getchar();
    return 0;
}

Here is the output:
enter image description here