Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,045 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,520 people online right now. Registration is fast and FREE... Join Now!




help

 
Reply to this topicStart new topic

help, can i get some help of how to make a calculator using c and switch ope

c help
4 Aug, 2008 - 06:33 AM
Post #1

New D.I.C Head
*

Joined: 4 Aug, 2008
Posts: 1

hey everyone i need lil help as to how to make a simple calculator using c and switch operation in it

User is offlineProfile CardPM
+Quote Post

jjsaw5
RE: Help
4 Aug, 2008 - 07:39 AM
Post #2

I vill break you
Group Icon

Joined: 4 Jan, 2008
Posts: 1,392



Thanked: 6 times
Dream Kudos: 125
Expert In: HTML, CSS, Database,

My Contributions
I would suggest doing a google search for this. There are a lot of tutorials out there for stuff like this, and you might want to check out our tutorials section here at D.I.C.
User is offlineProfile CardPM
+Quote Post

webmin
RE: Help
5 Aug, 2008 - 05:38 PM
Post #3

D.I.C Head
**

Joined: 21 May, 2008
Posts: 96


My Contributions
I won't give you the code on this but I would try this. First build four functions. One to add, one to subtract, one to multiply, and to divide. To make this as simple as possible each function should ask you for your numbers this way you don't have to worry so much about passing variables to to each function.

I would also create a menu this is really just artistic play on output in the console screen.

Then your switch statement should be able to direct you to each function depending on which one you choose. Keep in mind that switch statement can only go to functions that return an integral value, so your function should be declared something like int add (void);

If you need an idea of what a switch statement should look like check out this topic:
Grade Book

This is a program that I wrote which relies heavily on this switch statement. I built my switch statement in it's own function so that I could use the menu option selected in the rest of my program. In your case your won't have to do this, you can just do it in main. I would recommend though that you look up switch statements and especially on what you should do with a default statement as that will help you with data validation.

hope this helps
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 04:55PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month