*EDIT* okay. I feel stupid. Sorry. Just looking through my post, realized that the problem is probably in "loopcounter++", being directly after the second loop. Sorry, I should have checked through that better D: *EDIT*
Well shit. I was almost done typing my post, when I clicked outside of the text box and hit "backspace" by accident. :/
Anyways :D I'll start by saying that I am new to C++, and to coding, for the most part. I'm 15, and I've been intrigued by computers since I was 4. I've been using them avidly (or unhealthily) since then. I began writing simple "Qbasic" programs when I was 6. started taking apart computers when I was 7. (I actually just started getting paid for that, as I now have a job as a tech at a computer store, building custom PCs.
Anyways, I'm really interested in programming. Just the thought of being able to have complete control over a machine, or a program with just text is mind boggling to me. It's truly an amazing thing.
So, I decided to pick up a language. I chose C++ because it seems like a very "Trial and error" sort of language. I like problem solving :D
Okay, so. Now that my story's out of the way, I can explain my predicament :) This morning, I started on my first program. Not my
first first program, as that was
Hello World.
No, this is my first independent program, my first program without the help of a tutorial. My first program actually written by me.
What I was trying to do was get the program to count to 10, 10 times using loops. After every 10, it would show which loop it was on.
1
2
3
4
5
6
7
8
9
10
1
1
2
3
4
5
6
6
7
8
9
10
2
1
2...etc.
Of course, not the most useful program out there, but I thought it might have been a good training exercise.
Here is what I have so far:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
int numbercounter = 0; //variable counts to 10
int loopcounter = 0; //Variable counts the loops
int main()
{
while (loopcounter<10) { //First loop
while (numbercounter<10){ //second loop
numbercounter++; //Plus one to number
cout<< numbercounter; //displays number
cout<< "\n"; //next line
} //end of second loop
loopcounter++; //
cout<< " "
cout<< loopcounter;
cout<< "\n";
}
return 0;
}
|
I'm stuck :/ I've been working at it for an hour, and I can't get anything out of it D: I don't know what I did wrong, but it simply counts to 10 twice and kicks the bucket. It's probably something stupid that I missed.
I hope I don't sound like some spoiled kid who tries something out and quits the second he fails at it :P
Anyways, I'm sorry for the long introduction, just thought I'd shed a little light on the backstory, as I'm new here. Also, sorry for the stupid problem haha. Hopefully I'll get better at this with practice.
Thanks all :D
-dstrichit