Showing posts with label syntax. Show all posts
Showing posts with label syntax. Show all posts

Use of break ;

Reference > syntax of break 

switch(variable)
{
case value:
/*your code here*/
break;
 
case value:
/*your code here*/
break;
 
default:
/*your code here*/
break;
} 

if first case becomes true, break; will not allow the next case to use its code , break will take the control out of switch {} 


Switch case syntax

Reference > Syntax of Switch - case statements

switch(variable)
{
case value:
your code here

case value:
your code here

default:
your code here
} 


if first of the case is true all the cases bellow get executed  to prevent this we use break;



Do while loop

Reference > Syntax of do while loop 

 do
{
 your code
}while(condition);



While loop

Reference > Syntax of while loops in c and c++


while(condition)
{
code
}


For loop syntax


Reference > Syntax > syntax of for loop

The syntax of for loop in c and c++ is

 for(initialization; condition ; increment)
{
 code
}


Example of for loop

for(a=1;a<=10;a++)      /*displays hello 10 times then stop*/
{
printf("hello\n");

}