|
||||||
| C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
This is what I love about this forum. In most forums if someone asked a question common to new programmers(such as this question) they would get flamed.
__________________
<!-- comment comment comment --></ |
|
|||
|
sadly your right kromagnon, it usually does happen. Most of the members of this forum are beginners themselves, and they work together to learn something, which is always nice to see.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall |
| Sponsored Links |
|
|
|
|||||
|
It's important to know about the different kinds of loops and when to use each one. For instance, if you know you have to run something a certain amount of times(lets say 10 times), you'd use a for loop
Code:
for(int i=1; i <= 10; i++){
this action will be done 10 times, no more or no less(unless somehwere in the code the variable i is overridden and set to 10);
}
Code:
do{
cin >> length;
code actions
} while(length != 0);
|
|
|||
|
Perfect icepack (rep given). The main thing here is how you want to execute your loop. Like icepack said, if you need it to happen at least once use the do-while. In most cases you will see either the for or just the while.
__________________
Code:
for (int i;;) {
cout << "Smith";
}
|
|
|||||
|
Also, for-loops and do-while loops can always be done using a while loop. The choice to use one of the others is usually an indication of what your intention is.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Programming is a branch of mathematics. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| MySQL Loops | reachpradeep | Database & Database Programming | 0 | 03-04-2007 10:12 AM |
| JavaScript:Tutorial, Loops | TcM | Javascript | 4 | 12-13-2006 09:53 AM |
| JavaScript:Tutorial, Break Out Of Loops | TcM | Javascript | 0 | 12-08-2006 06:35 AM |
| WingedPanther | ........ | 2753.6 |
| Xav | ........ | 2704 |
| Brandon W | ........ | 1702.32 |
| John | ........ | 1207.73 |
| marwex89 | ........ | 1175.24 |
| morefood2001 | ........ | 966.05 |
| dcs | ........ | 655.75 |
| Steve.L | ........ | 475.59 |
| orjan | ........ | 418.58 |
| Aereshaa | ........ | 383.54 |