top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

C: Multiply two number and print them in traditional way as follows?

+3 votes
286 views

Input

520 * 12

Output

 1040
 520
 ----
 6240
posted Mar 31, 2016 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+2 votes
#include <stdio.h>

int main() {
    // your code goes here
    int num1,num2,mul,i; //we are multiplying num1 with num2
    char multiSign;
    fflush(stdin);
    scanf("%d%c%d",&num1,&multiSign,&num2);
    int sum=0;
    while(num2!=0)
     {
         mul=num1*(num2%10);
         printf("%d\n",mul);
         sum=sum+mul;
         num2=num2/10;
     }
     i=sum;
     while(i!=0)
      {
         printf("-"); //this will print "-" for required number of times
         i=i/10;
      }
     printf("\n%d",sum);
    return 0;
}
answer Apr 1, 2016 by Shahsikant Dwivedi
Similar Questions
0 votes

C program to find and print second largest digit in the given number? (without using arrays, functions and using only one loop).

0 votes

You are given 2 long integers having n digits each and you are required to multiply them using C.

Assumptions
Numbers are represented in an array of size n .
Calculate the time complexity using traditional divide and conquer

...