Important alert: (current site time 7/15/2013 4:59:03 PM EDT)
 

winzip icon

[[[ Basic Calculator ]]]

Email
Submitted on: 10/16/2002 4:24:39 PM
By: Mr.PoO 
Level: Beginner
User Rating: By 23 Users
Compatibility: C, C++ (general), Microsoft Visual C++, Borland C++, UNIX C++
Views: 49582
author picture
(About the author)
 
     This is the first program i made on Visual c++. Im a newb at c++ so be nice on me. Please leave comments and vote if you like it.
 
winzip iconDownload code

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come out every day, so no prevention program can catch 100% of them. For your own safety, please:
  1. Re-scan downloaded files using your personal virus checker before using it.
  2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com

 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.


Other 2 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

11/18/2002 6:04:37 PM

Hi, your code is very unprofessional. I would like to share with you the things you need to improve your code.
1) Name variables to something related to the subject. This is so you can easily understand what each does.
2) Add some useful comments in the code. You can easily forget what a certain thing does.
3) You used "int main()" but did not return a value. (my compiler caught this as a "warning". Warnings are very important so treat them like errors.
(If this comment was disrespectful, please report it.)

 
11/25/2002 1:35:55 PM

This code is very usefull for me. (I am a beginner too)
(If this comment was disrespectful, please report it.)

 
1/12/2003 9:01:36 PMRyanD

i agree with everything the first guy said, however not about returning a value from main as, in ANSI c++, the compiler automatically assumes it's returning 0. and you'd definately be better off learning to use switch statements for use anytime you have a console menu.
(If this comment was disrespectful, please report it.)

 
1/22/2003 3:45:29 PM

I agree with RyanD, int main() does not need to return a value, but just for neatness's sake, use void main().
(If this comment was disrespectful, please report it.)

 
1/22/2003 3:48:09 PM

nvm, dont use void main, I spaced..lol
(If this comment was disrespectful, please report it.)

 
1/26/2003 11:47:52 AM

heres a tip, from when i made my first calculator program. instead of having someone hit 1 for add, 2 for subtract, 3 for multiply, and 4 for divide, just have them enter the first number of the equation: E.X. 5, then enter a sign, which will be a char varible. a char is a character, like *. to make a char, type char VARIBLENAME; just like an int or long varible declaration. to test the chars, just put an if(VARIBLENAME=="/"){
answer=(firstnumber/secondnumber);
}

//that one up there would test if the person entered a / which would be division. after you have the char inputted, input for the second number. if you have any questions, just ask me.
(If this comment was disrespectful, please report it.)

 
1/26/2003 6:17:23 PMTrent McNitt

I'd say that you did a good job for your first program. But, you didn't (as the first guy stated) name your variables. Next time put comments in your code. And it is definately a good idea to get used to commenting just about anything you code. Whenever you use int main(), ALWAYS return a value. Most of the newer compilers just assume that you mean to return a value of 0, but not every compiler is the same. And that first guy was VERY right about treating warnings as errors! Anyways, it was a good first attempt. I would rate it higher then 3 because you DID succeed in making a calculator program, but you didn't do it very well.
(If this comment was disrespectful, please report it.)

 
4/3/2003 7:30:08 PMSifPer

I agree with everyone, but use a do-while loop so the process can be run again.

do
{
*main code*
cout<<"Another Calculation? (y/n)"< cin>>ch;
}while((ch=='y')||(ch=='Y'));
this will run the specified code until the user inputs overwise
-SiF
(If this comment was disrespectful, please report it.)

 
7/7/2003 4:00:43 AM

I have two things to say:

1. Good code for being a newbie (gotta start somewhere).
2. It would help other newbies.


(If this comment was disrespectful, please report it.)

 
10/11/2003 8:00:14 PM

Ummm, good code for begginer, but when I tried to compile it gave me at least 5 errors, but maybe it was my compiler, mine is Dev-C++
(If this comment was disrespectful, please report it.)

 
12/6/2003 11:09:52 AMflyzzx

This little app does help me :)

I'm just moving from VB to C++ and I got no idea how to operate C++, or how it works.

Now at least I have some ideas. thanks.
(If this comment was disrespectful, please report it.)

 
12/16/2003 8:44:08 AM

Works well but dosen't check for divide by zero error....!
(If this comment was disrespectful, please report it.)

 
12/17/2003 7:10:53 PM

A NooB Question in C++, what does

using namespace std;

Stand for???? E-mail me please
(If this comment was disrespectful, please report it.)

 
2/27/2004 12:53:05 PM

This is just a tip for your next program. Instead of having the user "press any key and enter to exit", you can replace

cin >>n;
if (n==' ')

with

system("pause");

This will allow the user to press enter only, without entering another character. Hope this helps.




(If this comment was disrespectful, please report it.)

 
6/19/2004 7:57:05 PM

I'm a beginner too, but I looked at your code and all I have to say is I could do better. If your bare bones beginner, I can understand, but if your a beginner, like me, you should really take the advice from the guy below me. Except to add on to his statement. Use void main because you aren't returning anything, and use a switch statement. Multiple if statements are a waste of code and it also makes the code look ugly.
(If this comment was disrespectful, please report it.)

 
6/19/2004 7:58:12 PM

I made a mistake. The first guy to make a comment
(If this comment was disrespectful, please report it.)

 
8/23/2004 7:54:37 AM

Why dont u use switch statements? It will save u loads of writing. :) Im a noob too
(If this comment was disrespectful, please report it.)

 
8/23/2004 7:55:29 AM

Why dont u use switch statements? It will save u loads of writing? Im a noob too :)
(If this comment was disrespectful, please report it.)

 
1/1/2005 1:41:57 AM

good try for a beginner. the last par where you use

if (n==' ')
{
return 0;
}

u can use a better code.
include the file

then instead of
if (n==' ')
{
return 0;
}
u use system("pause");
return 0;

_____________________________________

(If this comment was disrespectful, please report it.)

 
5/2/2005 4:30:02 PM

HI.my guid
PLease send me from robotics code on c/c++ becuase i want for programming robotic.
Thnaks for your help

(If this comment was disrespectful, please report it.)

 
6/20/2005 7:24:10 PM

This code is excelente, i started today with C++, and it is usefull, thanks!.
(If this comment was disrespectful, please report it.)

 
12/28/2006 4:16:53 AMChris C.

Hmmm.. I agree with the variable naming... another thing you should do is use a try{..} and cath{..} because if you type in a string, then your program will crash.
(If this comment was disrespectful, please report it.)

 
1/31/2007 1:25:17 PMganesh

nice post...
(If this comment was disrespectful, please report it.)

 
10/2/2007 2:41:06 PMthdespou

Try using several methods like switch/case or using less variables,you will learn many things this way!
(If this comment was disrespectful, please report it.)

 
9/25/2008 7:09:13 AMapol

thank you for sharing this code to students like me... i get some ideas how to create my own codes
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.