Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Control statement in c
1.
2. 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
3. Control
statement in
cShanu k k
shanukk89@gmail.com
www.facebook.com/shanunn
i
twitter.com/shanu
in.linkedin.com/in/shanu
9656153432
4. • C provides two sytles of flow
control:
• Branching
• Looping
5. If statement
• It takes an expression in parenthesis and an
statement or block of statements. if the
expression is true then the statement or block
of statements gets executed otherwise these
statements are skipped.
7. Switch statement
• A switch statement allows a variable to be
tested for equality against a list of values. Each
value is called a case, and the variable being
switched on is checked for each switch case.
17. • Intialization of control variable done
first using assignment statement
• The value of control variable tested
using test condition,ie reletional
expression such as i>10,that determine
when the loop will exit
• If the condition is true ,the body of
loop executed,otherwise terminated
19. additional features of for loop
1. More than one variable can be intialized atb a time
2. More than one variable incremented at a time
3. The thest condition may have compound relation
4. One or more sections can be omitted ,if necessary
eg:
m=5;
for(;m!=100;)
{
printf(“%dn”,m)
m=m+5;
}
20. Nesting of for loop
For(i=0;i<n;i++)
{
………………………………
For(j=0;j<n-1;j++)
{
………………………………
}
}
21. Jumping out of a loop
• Exit from a loop using break statement
if a break statement encounteredd in a
loop,the loop will immidiatly exited and the
program continues with the statement
immidiatly following loop;ie break will exit
only a single loop
23. Skipping a part of loop
Another statement ‘continue’,
• It tells the compiler skip the following statements
and continue with next iteration
Eg:
While (test condition)
{
………………………..
If(…………)
Continue;
25. 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