Skip to main content
gamedev.net
🔒 Locked

Stupid Question......

Started by wikedgamer 7 replies 200+ views
Original Post
wikedgamer
wikedgamer
I understand this is a stupid question and I feel embarrassed to even ask it but how can I go about learning the For/Do/While loops in C++? I just can''t memorize them! I wrote the code for each one like 30 times and then made the mistake of stepping away from the computer for 40 minutes to headbang to SLIPKNOT. When I sat back down, I was so confused, I was mixing them together by mistake! I just wanted to know how I could go about memorizing these loops so that I can finally move on with the book I have. Once again, I understand this might be a stupid question and for that I am sorry. WikedGamer
vtwin
vtwin
...hrm..what exactly is hard about memorizing these? They''re merely conditional statements.

A while loop can be nothing more than


  while(condition == true) {
}


That''s not exactly a lot of words to remember, eh? Sit down for a minute, repeat "while()" to yourself about 20 times..and you''ll be set. I''m sorry, I just can''t see how this is troubling you

If you really can''t remember a line of code like "for(int i=0;i<20; ++i)", than right it down with pencil on the top of your monitor or something. Right it down in notepad and save it somewhere.

This is a pretty easy problem to rectify, isn''t it..


swift URL | browse my bookmarks [server may not always be on]

Sensimed | Info/download
Neff
Neff
Just a quick word of advice:
Use the title of your post to describe your problem.

Otherwise, some really grumpy/wierd people will complain to you about wasting their time..
wikedgamer
wikedgamer
Well see, the book I am using presents the code like this:


#include <iostream.h>

main()
{
int i;
for(int i=1;i<=3;i++)
{
cout << i << '\n';
return 0;
}


I told you guys it was a very stupid question. I just can't seem to remember it for some odd reason. I'm trying so damn hard to memorize them. I really want to continue with the book I'm using ("Introduction to Computer Science using C++").

[edited by - wikedgamer on December 20, 2002 9:11:23 PM]
Neff
Neff
I feel for you. One of the best ways to learn something, is to just do it over and over. I would recommend repeating it in real situations. Write programs that do things with these loops.

Also, I noticed you mentioned head-banging to some head-bangable music. I have heard that, for example, listening to mozart for 10 minutes before a test actually improved elementary student''s grades. I listened to a trippy lsd trance mix once and couldn''t concentrate for the rest of the day, but I am a hypochondriac
I still would not recommend listening to most music while trying to or after learning something. But, who knows?

Good luck, and don''t despair!

return Neff;
wikedgamer
wikedgamer
Thanks Neff! I''ll put it to the test.
mutex
mutex
I didn''t learn for loops until halfway through my C++ career. Like Neff said, repeatedly using them will help you remember them. for loops can also be rewritten as while loops, and if for loops are too complex for you, you can just concentrate on while loops for now.

EvilTachikoma
EvilTachikoma
What exaclty is hard about memorizing them ? With while and do there is just one statement that can be true of false. With for, the first one initializes, the second one sests the condition and the third one defines the operation done to some variable every cycle - simple really

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.