![]() End-of-line Comment: begins with // and lasts till the end of the current line.Multi-line Comment: begins with a /* and ends with a */, and can span several lines.There are two kinds of comments in C/C++: Comments are not programming statements and are ignored by the compiler, but they VERY IMPORTANT for providing documentation and explanation for others to understand your program (and also for yourself three days later). Use a while-loop to repeatedly add 1, 2, 3., to the upperboundĬomments are used to document and explain your codes and program logic. Int absDiff // The absolute difference between the two sums // Prompt user for an upperbound Int upperbound // Sum from 1 to this upperbound Int sumEven = 0 // For accumulating even numbers, init to 0 Int sumOdd = 0 // For accumulating odd numbers, init to 0 * Sum the odd and even numbers, respectively, from 1 to a given upperbound. Read " Introduction To C++ Programming for Novices and First-time Programmers" if you need help in understanding this program. Basic Syntaxes Revisionīelow is a simple C++ program that illustrates the important programming constructs ( sequential flow, while-loop, and if-else) and input/output. The C++ compiler does not issue warning/error message for many obvious programming mistakes, undefined and unspecified behaviors, such as array index out of range, using an uninitialized variable, etc, due to the focus on performance and efficiency rather than the ease of use - it assumes that those who choose to program in C++ are not dummies. For example, to effectively use the C++ Standard Template Library (STL), you need to understand these difficult concepts: pointers, references, operator overloading and template, on top of the object-oriented programming concepts such as classes and objects, inheritance and polymorphism and the traditional constructs such as decision and loop. C++ is also a complex and difficult programming language, which is really not meant for dummies. ![]() C++ provides a huge set of reusable standard libraries, in particular, the Standard Template Library (STL).Ĭ++ is a powerful language for high-performance applications, including writing operating systems and their subsystems, games and animation. You can apply the same algorithm to different data types. C++ introduces generic programming, via the so-called template. ![]() The OO extension facilitates design, reuse and maintenance for complex software. C++ enhances the procedural-oriented C language with the object-oriented extension. Like C, C++ allows programmers to manage the memory directly, so as to develop efficient programs. C++ supports (almost) all the features of C.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |