Like Tree3Likes
  • 1 Post By EVOEx
  • 2 Post By Salem

Urgent Help for homework - sum and difference(100digits) with carry

This is a discussion on Urgent Help for homework - sum and difference(100digits) with carry within the C++ Programming forums, part of the General Programming Boards category; I am not good at programming, my teacher gave me to write a program and i have to finish it ...

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    2

    Exclamation Urgent Help for homework - sum and difference(100digits) with carry

    I am not good at programming, my teacher gave me to write a program and i have to finish it in 2 days. Here is the program which i have to write

    Write a program to determine the sum Z=X+Y and the difference Z=X-Y, where X, Y are n-digit integer decimal numbers and n<=100.
    He showed me how does it has to start but i need to complate it. an someone help me to finish my program, here is the what he wrote;

    Code:
    n= 100
    int x(100), Y(100), Z(101)
    
    for (i=0, i<n,i++)
    z[i]=x[i]+y[i]+c;
    if (z[i]>9)
    {c=1; z[i]=z[i]%10}
    who can create a C++ program from this content. and plus i need to write it for z=x-y too

  2. #2
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262
    Quote Originally Posted by Fatal1ty View Post
    who can create a C++ program from this content. and plus i need to write it for z=x-y too
    I can.
    manasij7479 likes this.

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,437
    In other words, you've made NO PROGRESS in the last 6 weeks.
    Urgent Help for homework - sum and difference


    Try this on paper
    Code:
    123456
       789 +
    ------
    If you don't understand this much, then find an elementary maths text book.


    Now imagine some boxes
    Code:
    +---+---+---+---+---+---+---+---+---+---+---+
    | 0 | 0 | 0 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | \0|
    +---+---+---+---+---+---+---+---+---+---+---+
    | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 7 | 8 | 9 | \0|
    +---+---+---+---+---+---+---+---+---+---+---+
    |   |   |   |   |   |   |   |   |   |   | \0|
    +---+---+---+---+---+---+---+---+---+---+---+
    Do the same, and keep track of which numbers go in which boxes.


    Now imagine those boxes as char arrays
    Code:
    char n1[10] = "0000123456";
    char n2[10] = "0000000789"
    char n3[10] = "";
    Repeat step 2, but mimic your actions as statements operating on the above arrays.
    rags_to_riches and kmdv like this.
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,648
    In other words, you've made NO PROGRESS in the last 6 weeks.
    All aboard the failboat!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Urgent Help for homework - sum and difference
    By Fatal1ty in forum C++ Programming
    Replies: 3
    Last Post: 03-28-2011, 12:01 PM
  2. Homework Correction !!Urgent!!
    By andryjohn in forum C Programming
    Replies: 12
    Last Post: 07-10-2009, 12:29 PM
  3. need urgent Homework help
    By zakimasmoudi in forum C Programming
    Replies: 2
    Last Post: 11-11-2007, 02:54 PM
  4. Urgent homework help for NEWBIE
    By Kazasan in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2004, 04:23 PM
  5. Urgent Maths Homework :(
    By (TNT) in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 01-09-2002, 08:01 PM

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