Thread: Calculator from char

  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    3

    Calculator from char

    Hi. I need help for a school project. I need to creat a calculator program using only getchar and putchar. the user has to enter the statement and the program should echo the statement and the answer. for example the user has to enter " 3 + 6 " and the program should answer " 3 + 6 = 9".
    I appreciate any help.

  2. #2
    uint64_t...think positive xuftugulus's Avatar
    Join Date
    Feb 2008
    Location
    Pacem
    Posts
    355
    Your efforts so far? Start by using getchar() to read in the user input into an appropriate
    character buffer. Then you can continue with processing the input, and then output the
    result.
    The general guideline for your task is:
    1. Read input
    2. Process input
    3. Calculate result
    4. Display result

    Post the code you manage to complete at each step.
    Code:
    ...
        goto johny_walker_red_label;
    johny_walker_blue_label: exit(-149$);
    johny_walker_red_label : exit( -22$);
    A typical example of ...cheap programming practices.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ ini file reader problems
    By guitarist809 in forum C++ Programming
    Replies: 7
    Last Post: 09-04-2008, 06:02 AM
  2. Sorting Linked Lists
    By DKING89 in forum C Programming
    Replies: 6
    Last Post: 04-09-2008, 07:36 AM
  3. code condensing
    By bcianfrocca in forum C++ Programming
    Replies: 4
    Last Post: 09-07-2005, 09:22 AM
  4. Passing structures... I can't get it right.
    By j0hnb in forum C Programming
    Replies: 6
    Last Post: 01-26-2003, 11:55 AM
  5. String sorthing, file opening and saving.
    By j0hnb in forum C Programming
    Replies: 9
    Last Post: 01-23-2003, 01:18 AM