### Ideas for a new guy

So basically i just started out with this language not too long ago (maybe a week and a half), and I was hoping to get some ideas of what I should try creating as far as a console application goes. I've done a calculator, but that's as much as my current skills go, and even then it would not have been possible without following along with a youtube tutorial. Also where should I continue as far as lessons go? I don't understand arrays very well but can manage with declaring variables and some other very basic concepts. Oh, and here's the calculator if there's any suggestions to improve.

 ``12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879`` `````` #include #include using namespace std; float addition(float num1, float num2) { return num1 + num2; } float subtraction(float num1, float num2) { return num1 - num2; } float multiplication(float num1, float num2) { return num1 * num2; } float division(float num1, float num2) { return num1 / num2; } int main() { float num1; float num2; int choice; cout<<"Choose your operation, 1= add, 2=subtract, 3=multiply, 4=divide" <>choice; if(choice==1) { //Addition section cout<<"you are adding, please enter the first number you would like to add. \n Number 1: "; cin>>num1; cout<<"please enter the second number you would like to add. \n Number 2: "; cin>>num2; cout<< "The answer is " << addition(num1, num2) <>num1; cout<<"enter the next number. \n Number 2: "; cin>>num2; cout<< "the answer is: " << subtraction(num1, num2) <>num1; cout<<"please enter the second number. \n Number 2: "; cin>>num2; cout<<"the answer is: " <>num1; cout<<"enter the second number. \n Number 2: "; cin>>num2; cout<<"the answer is: "<
Why so complicated? I wouldn't use functions and all that complicated stuff if I didn't know what they were. In my eyes, this would be much, much easier

 ``12345678910111213141516171819202122`` ``````#include using namespace std; int main () { int num1, num2, choice; cout << "Choose your operation: 1 add, 2 substract, 3 divide, 4 multiply"; cin >> choice; cout << "Enter first number..." << endl; cin >> num1; cout << "Enter second number..." << endl; cin >> num2; if (choice == 1 ) cout << "the result is " << num1 + num2; if (choice ==2) cout << "the result is " << num1 - num2; if (choice ==3) cout << "the result is " << (double)num1 / num2; if (choice ==4) cout << "the result is " << num1 * num2; cin.get(); cin.ignore(); return 0; }``````

Also, I suggest not learning anything new (arrays are complicated) until you understand basics : if statements and loops.
For cleaner code and more control, a switch method would be useful here for lines between 31 - 73. This isn't necessary as your program works great, just a good method to know. Read up on switches here: http://www.cplusplus.com/doc/tutorial/control/

For example:
 ``12345678910111213`` `````` switch (choice) { case 1: cout << "This is what happens if choice == 1"; break; case 2: cout << "This is what happens if choice == 2"; break; case 3: etc.... break; default: cout << "This is what happens if choice does not equal 1-3."; }``````
Last edited on
why don't you try to create a simple text-based RPG? that would use variables, conditions, and basic text input-output.

then, go for loops ("for" and "while").
@uzferry-I've taken your advice and am sticking to more basics for a little while.
@rcast- thanks! Reading that page currently.
@stauricus- will do.

Any programs I should attempt making besides a text based RPG?
Topic archived. No new replies allowed.