Disclaimer: This presentation is prepared by trainees of
baabtra as a part of mentoring program. This is not official
document of baabtra –Mentoring Partner
Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt .
Ltd
Week Target Achieved
1 25 20
2
3
4
5
6
7
Typing Speed
Jobs Applied
Week Company Designation Applied Date Current Status
1
2
3
JUNAIDVK
junaidvkomy@gmail.com
www.facebook.com/junaidomy
twitter.com/junaidomy
in.linkedin.com/in/junaidomy
9745991390
DIFFERRENT TYPE OF
CONTROL STRUCTURES IN C
CONDITIONAL STRUCTURES:
1) If statement
If the condition is true the statement inside the parenthesis{}, will be
executed, else the control will be transferred to the next statement after if.
Syntax:
if(boolean_expression)
{
/*statement(s) will execute if the boolean expression is true */
}
Else
{
/*statement(s) will execute if the boolean expression is false */
}
2) If else statement
In if else, if the condition is true the statements between if and else is
executed. If it is false the statement after else is executed.
Syntax:
if(condition)
{
Valid c statements;
}
else
{
Valid c statements;
}
3)Else if statement
In else if, if the condition is true the statements between if and else if is executed. If
it is false the condition in else if I checked and if it is true it will be executed. If none of
the condition is true the statement under else is executed.
Syntax: else if(condition n)
if(condition) {
{ valid c statements;
Valid c statements; }
} else
Else if(condition 1) {
{ valid c statements;
Valid c statements; }
}
-
-
4) Switch statements
Switch statement can also called matching case statement. If matches the value in
variable with any of the case inside, the statements under the case that matches will
be executed. If none of the case is matched the statement under default will be
executed.
Syntax: break;
switch(variable) default:
{ valid c statements;
case 1: break;
Valid c statements; }
break;
-
-
Case n:
Valid c statements;
LOOP STRUCTURES:
1) While
The most basic loop in C is the while loop. A while statement is like a repeating if
statement. Like an if statements, if the test condition is true : the statements get
executed. The difference is that after the statement have been executed, the test
condition is checked again. If it is still true the statements get executed again. This cycle
repeats until the test condition evaluates to false.
Syntax:
while(expression)
{
single statement
or
block of statements
}
2) Do while
Do while is just like a while loop except that the test condition is checked at the end of
the loop rather than the start. This has the effect that the content of the loop are always
executed at least once.
Syntax:
do
{
Single statement
Or
Block of statements;
}while expression;
3) For loop
For loop is similar to while, it’s just written differently. For statements are
often used to process lists such a rage of numbers:
Syntax:
For(expression1; expression2; expression3)
{
single statement
or
block of statements;
}
C PROVIDES TWO COMMANDS TO CONTROL HOW
WE LOOP:
1) BREAK
When break statement used in a loop, the loop is
im m ed iately term in ated an d p ro gram co ntro l res u m es
at th e n ex t statem ent fo llo win g th e lo o p .
Flow diagram:-
Syntax:
break;
2) CONTINUE
I t is s ometime d es irab le to s kip s ome
statem ents in s id e th e loop . I n s u ch cas es , contin u e
statement are used.
Flow diagram:
Syntax:
continue;
If this presentation helped you, please visit our
page facebook.com/baabtra and like it.
Thanks in advance.
www.baabtra.com | www.massbaab.com |www.baabte.com
Contact Us
Emarald Mall (Big Bazar Building)
Mavoor Road, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
NC Complex, Near Bus Stand
Mukkam, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
Start up Village
Eranakulam,
Kerala, India.
Email: info@baabtra.com
IKK Road,
East Hill, Kozhikode
Kerala, India.
Ph: + 91 – 495 30 63 624
NIT-TBI,
NIT Campus, Kozhikode,
Kerala, India.

Control structures in c

  • 2.
    Disclaimer: This presentationis prepared by trainees of baabtra as a part of mentoring program. This is not official document of baabtra –Mentoring Partner Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd
  • 3.
    Week Target Achieved 125 20 2 3 4 5 6 7 Typing Speed
  • 4.
    Jobs Applied Week CompanyDesignation Applied Date Current Status 1 2 3
  • 5.
  • 6.
    CONDITIONAL STRUCTURES: 1) Ifstatement If the condition is true the statement inside the parenthesis{}, will be executed, else the control will be transferred to the next statement after if. Syntax: if(boolean_expression) { /*statement(s) will execute if the boolean expression is true */ } Else { /*statement(s) will execute if the boolean expression is false */ }
  • 7.
    2) If elsestatement In if else, if the condition is true the statements between if and else is executed. If it is false the statement after else is executed. Syntax: if(condition) { Valid c statements; } else { Valid c statements; }
  • 8.
    3)Else if statement Inelse if, if the condition is true the statements between if and else if is executed. If it is false the condition in else if I checked and if it is true it will be executed. If none of the condition is true the statement under else is executed. Syntax: else if(condition n) if(condition) { { valid c statements; Valid c statements; } } else Else if(condition 1) { { valid c statements; Valid c statements; } } - -
  • 9.
    4) Switch statements Switchstatement can also called matching case statement. If matches the value in variable with any of the case inside, the statements under the case that matches will be executed. If none of the case is matched the statement under default will be executed. Syntax: break; switch(variable) default: { valid c statements; case 1: break; Valid c statements; } break; - - Case n: Valid c statements;
  • 10.
    LOOP STRUCTURES: 1) While Themost basic loop in C is the while loop. A while statement is like a repeating if statement. Like an if statements, if the test condition is true : the statements get executed. The difference is that after the statement have been executed, the test condition is checked again. If it is still true the statements get executed again. This cycle repeats until the test condition evaluates to false. Syntax: while(expression) { single statement or block of statements }
  • 11.
    2) Do while Dowhile is just like a while loop except that the test condition is checked at the end of the loop rather than the start. This has the effect that the content of the loop are always executed at least once. Syntax: do { Single statement Or Block of statements; }while expression;
  • 12.
    3) For loop Forloop is similar to while, it’s just written differently. For statements are often used to process lists such a rage of numbers: Syntax: For(expression1; expression2; expression3) { single statement or block of statements; }
  • 13.
    C PROVIDES TWOCOMMANDS TO CONTROL HOW WE LOOP: 1) BREAK When break statement used in a loop, the loop is im m ed iately term in ated an d p ro gram co ntro l res u m es at th e n ex t statem ent fo llo win g th e lo o p . Flow diagram:- Syntax: break;
  • 14.
    2) CONTINUE I tis s ometime d es irab le to s kip s ome statem ents in s id e th e loop . I n s u ch cas es , contin u e statement are used. Flow diagram: Syntax: continue;
  • 15.
    If this presentationhelped you, please visit our page facebook.com/baabtra and like it. Thanks in advance. www.baabtra.com | www.massbaab.com |www.baabte.com
  • 16.
    Contact Us Emarald Mall(Big Bazar Building) Mavoor Road, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 NC Complex, Near Bus Stand Mukkam, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 Start up Village Eranakulam, Kerala, India. Email: info@baabtra.com IKK Road, East Hill, Kozhikode Kerala, India. Ph: + 91 – 495 30 63 624 NIT-TBI, NIT Campus, Kozhikode, Kerala, India.