#if

If Statement in C++

if statement: The if statement is used to express the conditional expressions. If the given condition is true then it will execute the statements otherwise it will execute the optional statements. The basic simple structure of the if statement is shown below: if (expression) { //set of statements } The expression must be placed in round brackets as shown above. In this form, the set of statements would be executed only if the expression has a non-zero value (i.e., if expression is true). If the expression has a value zero (i.e., if expression is false), then the set of statements would be ignored by C++ compiler. The set of statements are skipped and the execution continues with the next statements. Example: Given below is a program which reads two numbers and then prints greater one using if statement. #include <iostream.h> void main() { int a, b; cout << “Enter Two...

Control Statements in C Plus Plus (C++)

Control statements alter the flow of execution of the programs. Control statements can be broadly divided into three categories: Decision-making or Conditional Statements (Branching and Selection) if statement if-else statement switch statement Loop Statements for statement while statement do-while statement Breaking Control Statements break statement continue statement goto statement

Preprocessor Directives in C++

The C++ preprocessor is a collection of special statements, called directives, that are executed at the begenning of the compilation process. The preprocessor is usually an integral part of our compiler. It is a process that is executed by the compiler before our C++ program code is compiled into machine instructions. The job of the preprocessor is to prepare our source code, proper for the compile phase, according to the instructions that we have included in the source files. These instructions are called preprocessor directives. All preprocessor directives begin with the symbol #, so they are easily distinguishable from C++ language statements. Given below is the complete set of preprocessor directives: Directive Function #include Supports header file inclusions #if, #else, #elif, #endif, #if defined (or #ifdef), #if !defined (or #ifndef) Enables conditional compilation #define, #undef Enable symbol and macro substitution #line Allows redefinition of current line and filename #error Produces...