Homework class help

This is a discussion on Homework class help within the C Programming forums, part of the General Programming Boards category; OK, so I have learned so far about getchar/putchar, arrays, varialbes, and control flows. and my homework is writing a ...

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

    Homework class help

    OK, so I have learned so far about getchar/putchar, arrays, varialbes, and control flows. and my homework is writing a program that gets an input from the user and read it char by char. The string has three parts:
    it has two non-negative numbers and an operator (*,-,/,+).
    I need to read this string and output the result of the given input.

    For example, a legal input 3.5+12 will get the output 15.5.

    I have to do this without using arrays and scanf function.
    Also, I am allowed to assume that the input is legal and that there
    is at least one space (' ') between the numbers and the operator.

    Okay, now you may ask-- so what is the problem?

    Well, everything went fine but for example when I enter: 10.345+10
    I get this: 10.345000+10.000000=20.345001.
    Another example is: 10.34 + 123.34, gives the output 10.340000+123.340004=133.680008.
    Last edited by nofear_k11; 09-02-2011 at 06:19 AM. Reason: removed code for the sake of homework policy

  2. #2

  3. #3
    Registered User
    Join Date
    Sep 2011
    Posts
    2
    I haven't read all of this, but from a glance, I think you mean that it is a relative error, and thus I don't have much to do, right?

    Interesting article, though.
    Thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. homework assistance wanted: using a class as a vector
    By DHart07 in forum C++ Programming
    Replies: 5
    Last Post: 11-02-2010, 02:12 PM
  2. homework help wanted - Class member functions
    By DHart07 in forum C++ Programming
    Replies: 16
    Last Post: 09-29-2010, 12:43 AM
  3. Replies: 27
    Last Post: 10-11-2006, 04:27 AM
  4. Replies: 7
    Last Post: 05-26-2005, 10:48 AM
  5. Template <class T1, class T2, class T3> error LNK2019
    By JonAntoine in forum C++ Programming
    Replies: 9
    Last Post: 10-11-2004, 12:25 PM

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