Paper Pencil Method of Multiplication

Discussion in 'C++' started by anniefaty, Sep 5, 2010.

  1. anniefaty

    anniefaty New Member

    Joined:
    Sep 5, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    can some one get me started on this c++ assignment.

    This lab is mainly an output-formatting exercise. It does require that you know how to develop the product of two integers, without using a calculator.

    Problem statement
    Write a program that multiplies two 4-digit positive integers and prints their product in the format below. Your program should ask the user to type the two numbers, then read them in. As an example, the product of 4560 and 4334 should produce the following output.
    Notice that the alignment should be the same as you’d get if you multiplied the numbers using a pencil and paper.

    4560
    x 4334
    ---------
    18240
    13680
    13680
    18240
    ---------
    19753920

    You have to pull out the digits of the top number. 1000th digit is ‘4’. So you’d then multiply ‘4’ time 4334. There are different ways of solving this.
     
  2. go4expert

    go4expert Moderator

    Joined:
    Aug 3, 2004
    Messages:
    306
    Likes Received:
    9
    Trophy Points:
    0
    You have to split the digit but getting the each digit.

    You have to divide by 10 and extract the remainder and then multiply it with the original number.

    Repeat the same for all digit and then display them.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice