// Lab 0 Lecture - Parts of a program // This is a working source file, so copy and paste the text into // your IDE and run it. // For the rest of the semester you will be downloading source files like // this one that will demonstrate the weeks material. Make sure to compile // and run them to see how the code works (press F9 in Code Blocks). You're // encouraged to modify and do your own testing to these programs as well. // Comments // You may have noticed that there are two '/' infront of each line so far. // this is the way you let the compiler know that you are writing comments. // comments are solely for the programmer to label and make notes about // their code. Comments do not affect how your program will run. // Another syntax for writing comments is shown below where // '/*' is the beginning of your comments and '*/' is the end // as shown below. This can be useful for commenting out paragraphs. /* * You may find commenting tedious, but it is extremely important to write * good comments so that you and others can more easily understand what is * going on. This is especially important when your programs get more complex. */ /* parts of a simple C++ program */ // preprocessor directive #include using namespace std; // main function declaration int main() // opening and closing braces indicate the beginning and end of the 'main' function { // statements that do stuff cout << "Look, you fool. You've got no arms left." << endl; cout << "Yes I have." << endl; cout << "Look!" << endl; cout << "It's just a flesh wound." << endl; // Exit the program return 0; } // A very useful tool that Code Blocks provides is the ability to comment out // sections of code. You can comment out a section of code by highlighting // the code you wish to comment out and pressing Ctrl+Shift+C. Likewise, // you can uncomment a section of code with Ctrl+Shift+X. Try commenting out // the above program. // (In Eclipse Ctrl+/ to both comment and uncomment)