Like Tree1Likes
  • 1 Post By quzah

how to write a program of a simple calculator?

This is a discussion on how to write a program of a simple calculator? within the C Programming forums, part of the General Programming Boards category; i'm new to the C programming. So, i need u guys help. i want to write a program of a ...

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

    how to write a program of a simple calculator?

    i'm new to the C programming. So, i need u guys help. i want to write a program of a calculator which can solve addition,subtraction, division and multiply. however, 0 cannot divide by any number. How to write this? write a program with explanation, please.I want to learn it.

  2. #2
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,650

  3. #3
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,866
    C Made Easy Tutorials. Start reading and then ask specific questions.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  4. #4
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by yeohwl91 View Post
    i'm new to the C programming. So, i need u guys help. i want to write a program of a calculator which can solve addition,subtraction, division and multiply. however, 0 cannot divide by any number. How to write this? write a program with explanation, please.I want to learn it.
    Nope, we're not going to write it for you. So follow the links in post #3 and start learning...

    Yer basic 4 banger calculator is very easily written and is a great learning exercise for students.

    Forget about source code for the moment...

    The best way to get started is to sit down with a few sheets of paper and a pencil and analyse the problem... what does it have to do? What choices does the user have? What functions does it perform? How does it inform the user of the results? And so on...

    Once you fully understand what is required, you can start planning your code. Work in small steps until you have a description of exactly what the program has to do in very small steps.

    The third step is to write your code from the plan you created.

    Finally test your code and make sure it works as expected.


    Notice that you don't actually start thinking about C or Source Code until the third step of this process. This is because nobody has ever solved a problem they don't understand.

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Code:
    #include<stdlib.h>
    int main( void )
    {
        system( "calc.exe" );
        return 0;
    }

    Quzah.
    CommonTater likes this.
    Hope is the first step on the road to disappointment.

  6. #6
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by quzah View Post
    Code:
    #include<stdlib.h>
    int main( void )
    {
        system( "calc.exe" );
        return 0;
    }
    ROFL ... now that's just nasty... effective... but nasty.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Write a program to model a simple calculator
    By Annihilate in forum C Programming
    Replies: 5
    Last Post: 11-22-2010, 12:14 PM
  2. Could someone please write a simple program for me?!
    By danjer242 in forum C++ Programming
    Replies: 1
    Last Post: 03-28-2010, 10:43 PM
  3. Replies: 15
    Last Post: 12-31-2007, 05:26 AM
  4. A Simple Calculator Program Not Working
    By oobootsy1 in forum C++ Programming
    Replies: 9
    Last Post: 01-09-2004, 08:34 PM
  5. Replies: 7
    Last Post: 07-19-2002, 04:33 AM

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