# How to make a calculator program using functions?

Page 1 of 1

## 2 Replies - 21012 Views - Last Post: 06 January 2008 - 04:39 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=40437&amp;s=e1fe33bcbea59f9d8730354dd1653596&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 baban

Reputation: 2
• Posts: 3
• Joined: 05-January 08

# How to make a calculator program using functions?

Posted 05 January 2008 - 11:37 PM

How can I make a calculator using functions??
Is This A Good Question/Topic? 0

## Replies To: How to make a calculator program using functions?

### #2 Louisda16th

• dream.in.assembly.code

Reputation: 15
• Posts: 1,967
• Joined: 03-August 06

## Re: How to make a calculator program using functions?

Posted 06 January 2008 - 12:00 AM

In case you don't know how to code the program, this should help get you started:
Write four functions: One for each arithmetic operation. The functions should each accept to arguments - the operands and return the result.
Ask the user to input two numbers and the operator in your main function.
Check what operator the user enters and call the appropriate function. You can use an if-else construct or a switch case construct (the latter would be better).
Output the answer in the main function itself.

Hope this helps .

### #3 baban

Reputation: 2
• Posts: 3
• Joined: 05-January 08

## Re: How to make a calculator program using functions?

Posted 06 January 2008 - 04:39 AM

baban, on 5 Jan, 2008 - 11:37 PM, said:

How can I make a calculator using functions??

Tnx... :-)