C++ the if statements

C++ The if statement:

The if statement is implemented in two forms

1. simple of statement
2. if else statement

Control Statements

In c programming, statements are executed sequentially or step by step in the order in which they are write in the program. Sometimes i want executes some parts of program on the basis of conditions. Also some times many situations arise where we want to use any statement or some statements several times.in all these conditions the control statements are use

Selection Statements Iterative Statements Jump Statements
if-else while statements break
Switch do-while statement continue
for statement goto

A compound statement is a block or group of statements enclosed within pair of curly braces {}. So the statements inside a block are execute sequentially

Here is general form of block

{
statement1;
statement2;
statement3;
……….
……….
……….
}

if-else

It is bi-directional selection control statement which used to take one action from two possible actions.so here is syntax of an if else statement

if(Expression)
{
statement1;
statement2;
………
}
else
{
statement3;
statement4;
……….
}

in above example this expression inside the parenthesis is evaluated if value inside the parenthesis is true (non-zero value), then statements of inside if block executed and if expression is false(zero) then statements of else block executed.

#include <iostream>
int main()
{
int a=10,b=6;
if(a>b)
{
std::cout<<"Bigger number = "<< a;
}
else
{
std::cout<<"Bigger number =" << b;
}
return 0;
}

  • C++ Dynamic Initialization of Objects
  • C++ Copy Constructor
  • C++ Dynamic Constructor
  • C++ Destructors
  • C++ Exercise
  • C++ Operator Overloading
  • C++ Overloading Unary Operators
  • Const pointer in C
  • Void pointer in c
  • C++ Overloading Binary Operators
  • C++ Overloading Binary Operators Using Friends
  • C++ Manipulation String Using Operators
  • C++ Rules for overloading operators
  • C++ Exercise
  • C++ Basic To class Type
  • C++ Class TO Basic Type
  • C++ One class To another class type
  • C++ Exercise
  • C++ Inheritance introduction
  • C++ Single Inheritance
  • C++ Multiple Inheritance
  • C++ Ambiguity Resolution in inheritance
  • C++ Hierarchical Inheritance
  • C++ Hybrid Inheritance
  • C++ Virtual Base Classes
  • C++ Exercise
  • C++ abstract class
  • C++ nesting of classes
  • C++ Exercise
  • C++ polymorphism
  • C++ Exercise
  • C++ pointers
  • C++ Pointers TO object
  • C++ this pointer
  • C++ Pointer to Derived class
  • C++ Virtual functions
  • C++ Exercise
  • C++ streams
  • C++ unformatted I/O operations
  • C++ Put() and get()
  • C++ getline() and write()
  • C++ Formatted console I/O
  • C++ Manipulators
  • C++ Exercise
  • C++ file handling
  • C++ file stream classes
  • C++ Open and closing file
  • C++ open using constructor
  • C++ open using open()
  • C++ Detecting End of file
  • C++ File modes
  • C++ File pointers and Manipulators
  • C++ Sequential I/O
  • C++ Reading and Writing
  • C++ Updating a File
  • C++ Error handling In File
  • C++ Command Line Arguments
  • C++ Exercise
  • C++ Template introduction
  • C++ Class Templates with multiple Parameters
  • C++ Function templates
  • C++ Function templates with multiple parameters
  • C++ member function Template
  • C++ Exercise
  • C++ Exception handling
  • C++ Basics of Exception Handling
  • C++ Exception Handling Mechanism
  • C++ Throwing Mechanism
  • C++ Catch Mechanism
  • C++ Catch all Exceptions
  • C++ Re-Throwing An Exception
  • C++ Specifying Exceptions
  • C++ Exercise