| shalito (1) | |
|
Hello I'm a real newbie on C++. I just started to learn it by my self and it really draws me in... I'm using a book: 'Beginning Programming with C Plus Plus for Dummies Ebook'. My question is about the semicolons: Why sometimes I use ";" and sometimes I don't, When do I have to and when do I not? I can't get used to it, I'm sure it maintains consistency, but i cant get to learn it, so i need some tips with that. Here is a piece of a code for example: while (nValue <= nTarget) <------- where is the ";" { cout << nAccumulator << " * " << nValue << " equals "; Thank you very much for reading it, And another big THANK YOU for trying to help a newb like me. | |
|
|
|
| Thumper (310) | |||
|
Hello, Shalito. Welcome to cplusplus forums :) When posting code, please use code tags, which can be found to the right of the text box (the <> button.) Semicolons are used at the end of every statement. Control structures, like while loops, for loops, and if/else are not considered 'statements' in the same sense. Think of them as structures who's bodies are enclosed in brackets. example:
Hope that cleared it up a little bit for you. | |||
|
|
|||