Thread: logical problem in c/c++

  1. #1
    Registered User
    Join Date
    Mar 2005
    Location
    indore
    Posts
    1

    logical problem in c/c++

    please reply soon so that we can get to some serious job.

    have problem in logic:

    "WRITE A PROGRAM IN C / C++ WHICH CAN ADD ANY TWO NUMBERS"

    * the length of number is undefined. i.e. it can be a 10 page long number .

    * for ex: the program should be able to add:

    12334345545656566767675675676768756454457645847578 48744787844354

    +

    76784358748745873457834545874654357884568758346587 45468756856578
    pls reply

  2. #2
    Information Crocodile
    Join Date
    Dec 2004
    Posts
    204
    This sounded like an interesting problem when i first read it, seemed really hard to do. Theres no variable type that can hold such large numbers( as far as i know ). Then i realized this could be done easily.

    You just make a solution similar to how you solve on paper.
    Adding evry number starting from the end of both inputs.

    "12345"
    + " 11"
    ---------------
    "12356"

    Output the solution as String.

    I hope you understand what i mean

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > please reply soon so that we can get to some serious job.
    If this is so you can get a job (or keep a job), then forget it.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  2. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  3. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  4. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  5. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 06:24 PM