Thank You For Coming My Blog. This Blog is Everyone so You Read and Share another...

Tuesday, March 26, 2019

Loops , Statements & Operators



LOOPS-
A Loop statement allows us to execute a statement or group of statements multiples times and following is the general form of a loop statement in most of the programming language. There are three types of Loop in C Language-
v For Loop
v While Loop
v Do…While Loop


While Loop in C Language-
A while Loop statement in c Language respectly executes a target statement as long as a given condition is true. When the condition false program control passes to the line immediately following the loop.
Syntax-       
while(condition)
{
Statement;
Increment or decrement;
}

For Loop in C Language-
A for Loop is a Repetition control structure that allows you to efficiently write a loop that needs to execute a specific number of lines. it is a simple loop in c language.
Syntax-
for(initialization;condition;counter)
      {                                                                                                                                                                                                               
Statement;
}
 
Do…while Loop in C Language-
A do…..while Loop is similar to a while loop, expect that a do…..while loop is guaranteed to execute at list one time. The do…while loop is checks the condition at the bottom of loop.



Syntax-
do
{
Statement;
 Increment or decrement;
}
while(condition);

Break Statement in C Language-
The Break Statement in c programming language has the two usages-
v When the break statement is encountered inside a loop, the loop is immediately terminated the program control resumes at the next statement following the loop.
v It can be used to terminate a case in the switch statement
Programs-
#include<stdio.h>
int main()
{
int a=10;
while(a<=20)
{
printf(“%d\n”,a);
a++;
if(a>15)
{
break;
}
}
return(0);
}
 
Continue Statement in C Language-
The Continue statement in c programming language works somewhat like
The break statement. Instead of forcing termination however continue   forces the next iteration of the loop to take place, skipping any code in between.
Programs-
#include<stdio.h>
int main()
{
int a=10;
do
{
if(a==15)
{
a=a+1;
continue;
}
printf(“%d\n”,a);
a++;
}
while(a<=20);
return(0);

Go to Statement in C Language-
A go to statement in c programming Language provides an unconditional jump from the goto a labeled statement in the same function.
Programs-
#include<stdio.h>
int main()
{
int a=10;
loop:do
{
if(a==15)
{
a=a+1;
goto loop;
}
printf(“%d\n”,a);
a++;
}
while(a<=20);
return(0);
}
}


OPERATOR->
1)-ARITHEMTIC OPERATOR
2)- RELATIONAL OPERATOR
3)- LOGICAL OPERATOR
4)- BITWISE OPERATOR
5)- ASSIGNMENT OPERATOR
6)- TERNAY OPERATOR

1)-ARITHEMTIC OPERATOR-

operator     -        Meaning
+       -        ADDITION
-        -        SUBTRACT
*        -        MULTIPLY
/        -        DIVIDE
%      -        MODULES

2)- RELATIONAL OPERATOR

 operator              -        Meaning
==              -        EQUAL TO
!=               -        NOT EQUAL TO
>                 -        GREATER THAN
<                 -        LESS THAN
>=              -        GREATER OR EQUAL TO
<=              -        LESS OR EQUAL TO

3)- LOGICAL OPERATOR

operator     -        Meaning
&&   -        AND
||        -        OR
!        -        NOT

4)- BITWISE OPERATOR

operator     -        Meaning
&      -        BITWISE AND
|         -        BITWISE OR
^        -        BITWISE XOR
~       -        UNARY
<<     -        BITWISE LEFT SHIFT
>>     -        BITWISE RIGHT SHIFT

5)- ASSIGNMENT OPERATOR

operator     -        Meaning
=       -        ASSIGNMENT OPERATOR
+=     -        ADD ASSIGNMENT OPERATOR
-=      -        SUBTRACT ASSIGNMENT OPERATOR
*=     -        MULTIPLY ASSIGNMENT OPERATOR
/=      -        DIVIDE ASSIGNMENT OPERATOR
%=    -        MODULES ASSIGNMENT OPERATOR
<<=  -        LEFT SHIFT AND ASSIGNMENT OPERATOR
>>=  -        RIGHT SHIFT AND ASSIGNMENT OPERATOR
&=    -        BITWISE AND ASSIGNMENT OPERATOR
^=     -        BITWISE EXCLUSIVE OR  AND ASSIGNMENT OPERATOR
|=      -        BITWISE INCLUSIVE OR AND ASSIGNMENT OPERATOR


6)- TERNAY OPERATOR

operator     -        Meaning
?        -        CONDITIONAL OPERATOR



No comments:

Post a Comment