C++ Tutorials

101. Using functions in C++

By: Emiley J : 2007-09-04

Description: While main() is a function, it is an unusual one. Typical functions are called, or invoked, during the course of your program. A program is executed line by line in the order it appears in your source code, until a function is reached. Then the program branches off to execute the function. When the function finishes, it returns control to the line of code immediately following the call to the function.


102. How to use Enumerated constants in C++

By: Emiley J : 2007-09-04

Description: Enumerated constants enable you to create new types and then to define variables of those types whose values are restricted to a set of possible values. For example, you can declare COLOR to be an enumeration, and you can define that there are five values for COLOR: RED, BLUE, GREEN, WHITE, and BLACK.


103. Demonstration of Prefix and Postfix operators in C++

By: Emiley J : 2007-09-04

Description: Both the increment operator (++) and the decrement operator(--) come in two varieties: prefix and postfix. The prefix variety is written before the variable name (++myAge); the postfix variety is written after (myAge++).


104. The if Statement in C++

By: Priya : 2007-09-04

Description: Normally, your program flows along line by line in the order in which it appears in your source code. The if statement enables you to test for a condition (such as whether two variables are equal) and branch to different parts of your code, depending on the result.


105. Advanced if Statements in C++

By: Priya : 2007-09-04

Description: It is worth noting that any statement can be used in an if or else clause, even another if or else statement. Thus, you might see complex if statements in the following form:


106. Use of Conditional (Ternary) Operator in C++

By: Baski : 2007-09-04

Description: The conditional operator (?:) is C++'s only ternary operator; that is, it is the only operator to take three terms.


107. Demonstrating global and local variables in C++

By: Priya : 2007-09-04

Description: Variables defined outside of any function have global scope and thus are available from any function in the program, including main().


108. Passing parameters to a function by value in C++

By: Priya : 2007-09-04

Description: The arguments passed in to the function are local to the function. Changes made to the arguments do not affect the values in the calling function. This is known as passing by value, which means a local copy of each argument is made in the function. These local copies are treated just like any other local variables. Program below illustrates this point.


109. Returning values from a function in C++

By: Abinaya : 2007-09-04

Description: Functions return a value or return void. Void is a signal to the compiler that no value will be returned.


110. Specifying default values to function parameters in C++

By: Abinaya : 2007-09-04

Description: For every parameter you declare in a function prototype and definition, the calling function must pass in a value. The value passed in must be of the declared type.