Facebook Twitter Instagram
Slider Image 1 Slider Image 2 Slider Image 3

Switch Statement

Switch statement is another structure used for selection decision making. In this structure we have multiple blocks of statements and only the selected block will be executed who’s case will be matched. We can use cases of both numeric and character data types.

Default Image

if-else if Statement

Another form of nested if-else if if-else if statement. It is use of else when there are more than one conditional statements that may all execute to true, yet you want only one if statement’s block to execute. You can use an “else if” structure, if statement and its body; that way, if the first statement is true, the “else if” will be ignored, but if the if statement is false, it will then check the condition for the else if statement. If the if statement was true, the else statement will not be checked. It is possible to use numerous else if statements to ensure that only one block of code is executed.

Default Image

Nested if-else

C++ allows us to use if-else statement in a nested form. Nested form is to use another if statement in an if statement. The if statement that contains another if statement is called outer if statement. The if statement that is inside outer if is called inner if statement. The control enters the inner if structure only when the condition of outer if statement is true.

Default Image

The Conditional Operator

Conditional operator is somehow substitute to the if-else structure. It is also used to make two-way decision as we made in if-else. We need three operands to complete conditional operator statement that’s why it called ternary operator. It is denoted by question mark (?) and colon (:). General syntax for conditional operator is: (condition)? statement1: statement2;

Default Image

if-else Statement

In this structure after execution of statement-1 if the given condition is true compiler will execute statement-2 if it is false then statement-3 execute.

Default Image

if Statement

if is the decision-making statement to check either condition is true or not. If condition is then the following code that is under the block of if will show output or further processing will be continue and if the given condition is false, then following statements will be ignored and program moved further.

Default Image

Logical Operators

Logical operators are used to generate more complex conditions for our programme. When we require to verify several conditions then we use logical operators. To build a logical condition we need two or more relational expressions.

Default Image

Relational Operators

As it is expressed from the name of operators these symbols are used to express some relation between two variables or quantities. In other words, we can say these symbols are used to compare. C++ have six operators that are used to compare values.

Default Image

Introduction to Selection Structure

In sequential structure of execution statements of a program execute one after one. Not a single statement of program skipped during execution. In some cases, we require to check condition and skip single or bunch of statements. This process of skipping statements can be done with the help of control structure. Control structure not only support skipping the statements but also support repeating of statements.

Default Image

cin Object

cin is the standard input object as like cout is the standard output object. It is used to get input from user. It helps to get any type of input in the programme, that may be an integer value, character or string. Input could be from a user through keyboard or from a file. It is used with extraction operator (>>) to receive input.

Default Image