loop_ex1.cpp – two different for loop examples for adding up even numbers.
loop_ex2.cpp – while loop example for adding up even numbers.
loop_ex3.cpp – while loop example for finding the largest number less than 10,000,000 and divisible by 63.
loop_ex4.cpp – while loop example for allowing user to enter an arbitrary amount of input.
Absolute C++ 6/E 2.3
LECTURE 6: Functions I
We will learn how to use predefined functions in libraries such as cmath and ctime. In addition to using predefined functions we can also create our own functions and use them in our programs. We will also start to learn about programmer-defined functions.
Today we’ll learn about file input and output using streams. How to write to files, read from a file and append to a file. Our file input and output example will also introduce arrays. Although arrays are not the main topic of the lecture they are an important programming language concept. Next, we’ll learn how to handle when a file fails to open. To assist with the example we will learn about the the chmod Linux command.
Overview of how to properly document your programs including in-program documentation and API documentation. We will also learn about code style – best practices for how to write and organize your programs. Examples of code style include best practices for indentation, white space, line length, comments, naming conventions and file structure.
pointers_ex2.cpp – an example of how to pass a pointer variable to a function as a call-by-value parameter. This is the first of two examples that highlight the difference between passing a pointer as a call-by-value vs. call-by-reference parameter. [YouTube & YouTube]
LECTURE 16: Dynamic variables
Using pointers to create dynamic variables and dynamic arrays.