1. Data Type:
While doing programming in any programming language, you need to use various
variables to store various information. Variables are nothing but reserved
memory locations to store values. This means that when you create a variable you
reserve some space in memory. They can be classified into many types.
Character Type:
They can represent a single character, such as 'A' or '$'.
The most basic type is char, which is a one-byte character. Other types are
also provided for wider characters.
Numerical Integer Type:
They can store a whole number value, such
as 7 or 1024. They exist in a variety of sizes, and can either
be signed or unsigned, depending on whether they support negative values
or not.
Floating Point Type:
They can represent real values, such
as 3.14 or 0.01, with different levels of precision, depending on which of
the three floating-point types is used.
Boolean Type:
The Boolean type, known in C++ as bool, can only
represent one of two states, true or false.
Loops:
It is a statement that is used to repeat set of statements up to a fixed
number of times or until a given condition is satisfied.
Or
To perform a repetitive task in a certain condition called a loop.
2. There are three types of loops in c++ programming.
For loop.
While loop.
Do while loop.
For loop:
Execute a statement repeatedly until the condition become
false.
Syntax:
For (int; condition; increment)
{
Statement;
}
While loop:
A while loop statement repeatedly executes a target
statement as long as a given condition is true.
Syntax:
While (condition)
{
Statement;
}
Do while loop:
Unlike for and while loops, which test the loop condition
at the top of the loop, the do...while loop in C programming language checks its
condition at the bottom of the loop.
3. Syntax:
Do
{
Statement;
} while (condition);
Statement:
If statement:
An if statement consists of a Boolean expression followed
by one or more statements.
Syntax:
If (condition)
{
Statements
}
If else statement:
An if statement can be followed by an
optional else statement, which executes when the Boolean expression is false.
Syntax:
If (condition)
{
Statements
}
Else
4. {
Statements
}
If else if else statement:
An if statement can be followed by an
optional else if...else statement, which is very use full to test various conditions
using single if...else if statement.
Syntax:
If (condition 1)
{
Statements
}
Else if (condition 2)
{
Statements
}
Else
{
Statements
}
Nested If-Else Statement:
An If statement inside another if statement
Is termed as nested statement.
OR
5. It is a conditional statement which is used when we want to check more than 1
conditions at a time in a same program. The conditions are executed from top to
bottom checking each condition whether it meets the conditional criteria or not.
If it found the condition is true then it executes the block of associated
statements of true part else it goes to next condition to execute.
Syntax:
if(condition)
{
if(condition)
{
Statements;
}
else
{
Statements;
}
}
else
{
Statements;
}