Beginner in C facing problem

This is a discussion on Beginner in C facing problem within the C Programming forums, part of the General Programming Boards category; Hi! Could you plz help me in the following question: "Write an interactive program to demonstrate the process of multiplication.The ...

  1. #1
    Registered User
    Join Date
    Aug 2007
    Location
    INDIA
    Posts
    13

    Unhappy Beginner in C facing problem

    Hi!
    Could you plz help me in the following question:
    "Write an interactive program to demonstrate the process of multiplication.The process should ask the user to enter two 2-digit numbers(integers) and print the product of the integers as shown below:

    45
    x 37
    --------------
    315 (7x45)
    135 (3x45)
    ---------------
    1665 (Add them)
    ---------------

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,718
    What have you tried?
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,801
    For the example provided, you'd need to split the bottom multiplier 37 into it's component pieces 3 and 7. This can be done with some simple math using division (/) and modulus (&#37 operators: What is 37 / 10? What is 37 % 10?
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  4. #4
    Registered User
    Join Date
    Aug 2007
    Location
    INDIA
    Posts
    13
    #include <stdio.h>
    void main()
    {
    int ax,by,a,b,c,d,e;
    printf("Enter any two 2-digit integers");
    scanf("&#37;d %d",&ax,&by);
    c=ax*(by-10*b);
    d=ax*((by-y)/10); /*here I have broken 37 as
    scanf("%d %d",&c,&d); 3*10+7 i.e" by=10b+y"*/
    e=c+10*d;
    printf("The product is %d",e)
    Last edited by paushali; 10-30-2007 at 11:47 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 15
    Last Post: 12-13-2008, 08:32 AM
  2. Replies: 5
    Last Post: 11-07-2005, 10:34 PM
  3. searching problem
    By DaMenge in forum C Programming
    Replies: 9
    Last Post: 09-12-2005, 01:04 AM
  4. Bin packing problem....
    By 81N4RY_DR460N in forum C++ Programming
    Replies: 0
    Last Post: 08-01-2005, 05:20 AM
  5. beginner function problem
    By dellebelle751 in forum C++ Programming
    Replies: 7
    Last Post: 10-30-2002, 06:12 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21