Syntax in C++
Syntax is defined as a way of writing a program. It just like when we write English Sentences we think about grammar that our sentence should be grammatically right...same thing with the program's Syntax is like a grammar in our programs.
" The Valid Structure of Statement in a program is called Syntax. "
# if Syntax
if(condition)
{
block statement1;
}
# if else Syntax
if(condition)
{
block statement_1;
}
else
{
block statement_2;
}
# if else ladder Syntax
if(condition)
{block statement1;}
else
if(condition1)
{block statement2;}
else
if(condition2)
{block statement3;}
else
{default statement4;}
# switch syntax
switch(choice)
{
case 1:
statement 1;
break/continues;
case 2:
statement 2;
break/continues;
case 3:
statement 3;
break/continues;
.
.
.
case n:
statement n;
Default: default statement;
}
# while loop Syntax
while(condition)
{
statement1;
statement2;
.
.
statement n;
}
# do while loop Syntax
do
{
Statements;
}while(condition);
# for loop syntax
for(initialization; condition; increment/decrement)
{
Statements ;
}
By - Somesh Sah
Comments
Post a Comment