First Basic Calc.

Posts 1–12 of 12 · Page 1 of 1
First Basic Calc.
Code:
//This is practice using variables. attempt #2 to make a basic add,sub.,multi.,divide calculator :)

#include "stdafx.h"

#include <iostream>
#include <string>

using namespace std;
int main ()
{
	double a;
	double b;
	double result;

	cout << "Please enter #1" << endl;
	cin >> a;  //cIN tells the program to store any variable/integer for future use and set it as "a"
	;

	cout << "Please enter #2" << endl;
	cin >> b;  //cIN tells the program to store any variable/integer for future use and set it as "b"
	;

	cout << "#1 plus #2 is: ";
	result=a+b;  //tells the program to add a to b
	cout << result << endl;
	cout << " " << endl;


	cout << "#1 minus #2 is: ";
	result=a-b;  //tells the program to subtract b from a
	cout << result << endl;
	cout << " " << endl;


	cout << "#1 times #2 is: ";
	result=a*b;  //tells the program to multiply a by b
	cout << result << endl;
	cout << " " << endl;

	cout << "#1 divided by #2 is: ";
	 result=a/b;  //tells the program to divide a by b
	cout << result << endl;
	cout << " " << endl;
	
	cout << "This is kAblE's first calculator in cpp" << endl;
	cout << "Thanks for using it!" << endl;

	system ("pause");


	return 0;
}
Thanks to Generist for helping me with my errors and the fact that I forgot to include cin
nice to see that you started in the right way.. (with the basics actually) keep with it ^^
Quote Originally Posted by 'Bruno View Post
nice to see that you started in the right way.. (with the basics actually) keep with it ^^
Thanks :DDD
Quote Originally Posted by 'Bruno View Post
nice to see that you started in the right way.. (with the basics actually) keep with it ^^
Agreed. All this simple stuff becomes very important later on, so its best to understand it now so you don't have to worry about it when everything else becomes complicated.
Oh snap, he's already learned how to use operators. At this rate, he'll pass Cap'n Why in....a few months. Me in 2-3 days.

Nice job.
Yay now try more advanced operations like value storing and trigonometry and logarithmic functions
JK lol don't brainphuck urself
It's a good start, next you can go onto switches, or goto's.

Only thing I didn't like was your code format, the randomly placed results were odd.

And the semi-colons, and the

Code:
cout << "  " << endl;
could just be end lines or escape sequences.
Quote Originally Posted by litebrand View Post
It's a good start, next you can go onto switches, or goto's.

Only thing I didn't like was your code format, the randomly placed results were odd.

And the semi-colons, and the

Code:
cout << "  " << endl;
could just be end lines or escape sequences.
I didn't learn about the \n command when I made that so I thought a space wouldn't be to bad of a replacement
Quote Originally Posted by KABLE View Post
I didn't learn about the \n command when I made that so I thought a space wouldn't be to bad of a replacement
You don't need the \n command
You can use

Code:
cout << result << endl << endl;
Instead of

Code:
cout << result << endl;
cout << " " << endl;
Quote Originally Posted by Pixipixel_ View Post


You don't need the \n command
You can use

Code:
cout << result << endl << endl;
Instead of

Code:
cout << result << endl;
cout << " " << endl;
I'ma still learnin'
Quote Originally Posted by Pixipixel_ View Post


You don't need the \n command
You can use

Code:
cout << result << endl << endl;
Instead of

Code:
cout << result << endl;
cout << " " << endl;
Pretty good suggestions actually :P
nice job better then Wat i could do
Posts 1–12 of 12 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?