Defining cin, cout, endl, and ;

Alright, I've made a few post in the last few days because my professor is giving us some ridiculous stuff for our midterm. I've done really well so far this semester (97.4) and he's throwing us some questions that I don't even know how to answer.
Defining cin, cout, and endl was easy. But I can't really put words to the semi colon... I know how to use it, but how is it defined?
Maybe this will come easier to someone else.
closed account (Dy7SLyTq)
well, im just now getting into compiler stuff, so i wont be using the right terms, but what it does is it shows that the current command is finished. technically it doesnt need it and use EOL like python or bash (if you make the code for it), but its there to define the end of a command
I worked with python in highschool and I'm in my second semester of college using c++. I don't even know why I couldn't think of it, just kinda blanked.
I appreciate your reply though.
A semicolon tells the compiler that it has reached the end of a statement.

But there are other uses for it as well - can you think what they are?
closed account (Dy7SLyTq)
comments an assembly
There are much more obvious examples than that. I can think of 3 really obvious ones.
closed account (Dy7SLyTq)
do you mean intended use, or creative use, like making a while-if loop to emulate a do-while loop in python?
Just normal bog standard C++. 2 of them are very similar, all 3 are things one uses very frequently.
closed account (Dy7SLyTq)
ummmmm.... i dont think you mean the end of a do while loop... ah wait, structs, classes, enums, unions? i know this is more than three although im gonna make my top three do while, enums, and classes
Well, good.


But there is 1 more - it is a keyword - think about it for awhile.
closed account (Dy7SLyTq)
i have to leave for work in two minutes so ill reply when i get back
There is also initialisation off arrays:

1
2
3
4
int MyArray[2][2] = {
     {5,7}
     {2,3}
};


That brings me to the earlier comment:

technically it doesnt need it and use EOL like python or bash (if you make the code for it), but its there to define the end of a command


As you can see '\n' is not sufficient.

There is still one more basic thing that uses semicolons, that we haven't covered yet - I actually mentioned it in my last post.

closed account (Dy7SLyTq)
yes ur right. i didnt think of that. is it the for loop
Topic archived. No new replies allowed.