Read 2 numbers
Print multiplication as in following example:

Prepare following functions
Modulo division (you cannot use '%')
Print a number with leading and "following" spaces

Please I need to do that in C language, I think the best way to do it is converting to a array the second string that you enter by keyboard, then we must multiplicathe that array one by one to have the partial multiplications. Finally we have to put it in the correct position (I don't know how to do it) and print the multiplication result at the end.

Thank you very much!

Recommended Answers

where is ur program code???

Jump to Post

All 3 Replies

#include <cstdlib>
#include <iostream>
#include "conio.h"

using namespace std;

int main(int argc, char *argv[])

int num1=0,num2=0,res=0;
printf("Please, enter a number: ");
printf("\n By this other number: ");
for(int cont=0;cont<num2;cont++)
printf("The result is: %d \n",res);


Well, since you mentioned array, you can try this:

int num2[10], num1;

/* Input num1 here */

/* Multiplication part */
for(cont = i - 1, n = 0; cont >= 0; cont--, n++) {
    res = res + ( (num1 * num2[cont]) * pow(10, n) );

This is nothing but,
eg: 1234 * 22

x   22 
--------   _
    88      |
   660      |==>  pow(10, n) is used for this i.e purpose, multiplication by powers of 10.
  4400      |
 22000     _|

So, basically, input one of the numbers into an array. (getchar() can be used as shown)

while ( (c = getchar()) != '\n') {
        num2[i++] = c - '0';

So, the elements are in the array. All that's left is the multiplication, which has been shown above.

Is this what you were looking for?

PS: Please use code-tags for posting code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.