Hi! I'm getting into programming, taking some classes, etc. Figured I'd look around for a programming forum so I could keep up with the community at large. :)
At any rate, I'm mainly learning C++. My classes don't start 'till Friday, but I'm following some online tutorials. The input/output commands, if/else statements, loops, variables, and so forth all seem fairly easy. But then all of a sudden the difficulty ramps up fast. :p
I've seen from reading various threads around here that people have vastly different learning styles for learning a new programming language. I think I'm more of a "set a difficult goal and jump in, finding out what I need to do to achieve it" kind of learner. My current goal is to make a colored square in the center of the screen that will move around when I hit the arrow keys. Don't tell me! I'll figure it out. :D
Hello!
Started by MerakSpielman, Jan 16 2008 08:09 AM
8 replies to this topic
#1
Posted 16 January 2008 - 08:09 AM
|
|
|
#2
Guest_Jordan_*
Posted 16 January 2008 - 08:41 AM
Guest_Jordan_*
Hey MerakSpielman, welcome to CodeCall. I believe I learn in a similar way. I can get only so much knowledge from a book but once I jump in I start learning more rapidly. If you need any help, let us know.
#3
Posted 16 January 2008 - 08:44 AM
hm.... right now I'm trying to figure out why the cin.get(); function is working properly at two places in my program, but not in a third place. It doesn't even stop there and wait for input. Is it somehow skipping that line? How strange...
edit: got it.
edit: got it.
#4
Posted 16 January 2008 - 09:10 AM
teehee! This is fun!
#include <iostream>
using namespace std;
int main ()
{
int n1, n2, n3;
cout << "We are going to add together two numbers! (Press Enter to continue)";
cin.get(); //this is the command for requesting the user to press enter
while (n3!=0) {
cout << endl << "All right... what is your first number? ";
cin >> n1;
cout << endl << "Very well... " << n1 << " is your first number. Wise choice. What is your second number? ";
cin >> n2;
n3 = n1 + n2; //adding the two numbers
cout << endl << "Really? " << n2 << " is your second number? Truly astonishing!" << endl << endl;
cout << "When you're ready to see the sum of your numbers, please press Enter.";
if (n3!=0) {
cin.get();
cin.get(); //for some reason I had to put the same line in twice to get it to work properly. Not sure why.
cout << endl << endl << "The sum of " << n1 << " and " << n2 << " is.... " << n3 << "!!!!" << endl << endl;
cout << "Let's do it again! If you're done adding numbers, just choose 0 and 0 for your numberes, and the program will terminate." << endl << endl;
}
}
return 0;
}
#5
Posted 16 January 2008 - 12:53 PM
#6
Posted 16 January 2008 - 03:41 PM
Welcome aboard. I'm in the same boat as yourself, learning C++.
I know this is the introductory post but since you posted some code it seems like you came across the old 'console will not stay open so at least I can view the results' issue.
I generally put either one of these at the end of the main program:
I know this is the introductory post but since you posted some code it seems like you came across the old 'console will not stay open so at least I can view the results' issue.
I generally put either one of these at the end of the main program:
// exit routine cout << "\n\n...Press ENTER to Exit System..."; cin.get(); return 0;or if that doesn't work, and there are reasons why it wouldn't, I move onto this:
// exit routine cout << "\n\n...Press ENTER to Exit System..."; cin.clear(); while (cin.get() != '\n') continue; cin.get(); return 0;
#7
Posted 16 January 2008 - 06:00 PM
#8
Posted 16 January 2008 - 10:06 PM
Welcome to CodeCall, MerakSpielman!
#9
Posted 17 January 2008 - 09:03 AM
Welcome to Codecall.
Enjoy your stay
Enjoy your stay


Sign In
Create Account


Back to top









