The document discusses various control flow statements in C programming such as decision control statements (if, if-else, switch-case), looping statements (for, while, do-while loops), break, continue, goto, and functions. It provides examples of using each statement type and explains their syntax and usage. Key aspects like scope of variables, parameter passing methods (call by value, call by reference), and storage classes (auto, static, extern) related to functions are also covered in the document.
Module 2 - Control Structures c programming.pptm.pdfSudipDebnath20
The document outlines control structures in C programming, critical for managing the flow of execution. It categorizes them into three main types: sequence, selection, and loop structures, detailing various forms such as if, if-else, nested if-else, switch-case for selection, and for, while, do-while loops for repetition. Practical examples are provided to illustrate how each control structure is implemented and used in programming scenarios.
PROBLEM SOLVING USING NOW PPSC- UNIT -2.pdfJNTUK KAKINADA
The document covers control flow, relational expressions, and arrays in C programming, detailing conditional branching statements such as if, if-else, switch, and loop structures including for, while, and do-while loops. It explains arrays as collections of elements of the same data type and discusses their operations, specifically one-dimensional and multi-dimensional arrays. Additionally, it describes unconditional control statements like break, continue, and goto for flow management in programs.
The document discusses different types of control statements in C programming including decision control statements, iteration statements, and transfer statements. It provides details about if, if-else, switch, while, do-while, for loops. Decision control statements like if, if-else, switch allow altering the flow of execution based on certain conditions. Iteration statements like while, do-while, for are used to repeat a block of code until the given condition is true. They allow looping in a program.
The document discusses input and output functions in C programming. It describes the printf() and scanf() functions for output and input. printf() displays output and can print variables and messages. scanf() reads input from the keyboard and stores it in variables. It also discusses control flow statements like if-else, switch case, loops (while, do-while, for), and statements like break, continue, and goto.
The document discusses control statements in C programming. It covers various selection statements like if, if-else, switch as well as iteration statements like for, while, do-while loops. Nested loops and special control statements like break, continue and goto are also explained. Operators used in control statements like relational, logical, assignment operators are defined along with examples. The different types of loops and their usages to control program flow are demonstrated.
2. Control structures with for while and do while.pptManojKhadilkar1
This document introduces various control flow statements in C programming including decision control statements like if, if-else, else-if ladder and switch statements. It also covers loop control statements like while, do-while and for loops. It provides the syntax and examples of using each statement. Key points covered include using break, continue and goto to alter normal program flow, and the exit() function to terminate a program.
The document discusses various control structures and functions used in Arduino programming including decision making structures like if, else if, else statements and switch case statements. It also covers different types of loops like while, do-while and for loops that allow repeating blocks of code. Functions are described as reusable blocks of code that perform tasks and help organize a program. Strings can be implemented as character arrays or using the String class, and various string functions are provided to manipulate and work with strings.
The document provides an introduction to programming in C and explains key concepts like variables, input/output, control structures (if/else, for loops, do-while loops), and switch statements through examples. It defines variables as locations for temporarily storing values, describes how the scanf function is used for input and printf for output, and explains how control structures like if/else and loops allow conditional or repeated execution of code. The examples given illustrate how each concept works in a C program.
Btech i pic u-3 handling input output and control statementsRai University
The document discusses various control statements in C programming language including if-else statements, switch statements, loops (while, do-while, for loops), and jump statements like break, continue, goto. It provides examples of each statement and explains their usage and flow. Key control statements covered are if-else, switch, while, do-while, for loops, break, continue. Nested control structures and their flow is also explained with examples.
Diploma ii cfpc u-3 handling input output and control statementsRai University
This document discusses control statements and looping in the C programming language. It covers if-else statements, switch statements, the ternary operator, goto statements, while loops, do-while loops, for loops, and nested loops. It provides examples of each construct and describes how they control program flow. Jump statements like break and continue are also covered, allowing programs to exit or skip parts of loops.
The document discusses various control statements in C programming including selection statements like if, if-else, switch and iteration statements like for, while, do-while. It explains how to use these statements to control program flow through conditional execution and selection. Some key concepts covered include nested if statements, the dangling else problem, switch vs if-else statements, testing equality in loops, and using break, continue and goto statements. The document also provides examples of using control statements to find the largest of three numbers and calculate a factorial.
The document discusses various control statements in C programming including selection statements like if, if-else, switch and iteration statements like for, while, do-while. It explains how to use these statements to control program flow through conditional execution and selection. Some key concepts covered include nested if statements, the dangling else problem, switch vs if-else statements, testing floating point equality in loops, and using break and continue statements. The document also provides examples of various control structures like if-else ladder, nested loops and using goto statements.
Mca i pic u-3 handling input output and control statementsRai University
The document discusses various control statements in C programming language including if-else statements, switch statements, loops (while, do-while, for loops), and jump statements like break, continue, goto. It provides examples of each statement type and explains their usage and flow. Key control statements covered are if-else, switch, while, do-while, for loops, and how to exit or continue within loops using break, continue and goto statements.
handling input output and control statementsRai University
The document discusses various control statements in C programming language including if-else statements, switch statements, loops (while, do-while, for loops), and jump statements like break, continue, goto. It provides examples of each statement and explains their usage and flow. Key control statements covered are if-else, switch, while, do-while, for loops, break, continue. Nested control structures and their flow is also explained with examples.
Loops in C are used to execute a block of code repeatedly until a specified condition is met, allowing for more efficient coding by reducing the number of lines required. There are three types of loops: while, for, and do-while, each with distinct structures and uses. While loops check the condition before executing, for loops allow more control with initialization and increments, and do-while loops ensure the body executes at least once before checking the condition.
Loops in C are constructs that allow a set of statements to be executed repeatedly until a specified condition is met, resulting in code efficiency and ease in managing repetitive tasks. There are three main types of loops in C: while loop, for loop, and do-while loop, each functioning in slightly different ways with specific syntax. Additionally, infinite loops can occur if the conditions for termination are not properly defined.
The document discusses control statements in C programming, focusing on how they dictate the execution order of instructions. It covers various types, including sequence, decision, case, and loop statements, with particular emphasis on if-else, switch statements, and three types of loops: for, while, and do-while. Additionally, it highlights the use of continue, exit, and goto statements for controlling program flow.
The document summarizes common repetition structures in C programming including while, do-while, for loops as well as break, continue, and exit statements. It explains that repetition structures allow code to execute repeatedly while a condition is true and covers the syntax and usage of each structure.
Bsc cs pic u-3 handling input output and control statementsRai University
The document discusses various control statements in C programming language including if-else statements, switch statements, loops (while, do-while, for loops), and jump statements like break, continue, and goto. It provides examples of each statement type and explains their usage and flow. Key control statements covered are if-else, switch, while, do-while, for loops, and how to exit or continue within loops using break, continue and goto statements.
The document discusses decision-making in C programming, covering various constructs such as if statements, switch statements, conditional operators, and goto statements. It explains the usage, syntax, and examples for each construct, as well as loops in C, including while, for, and do-while loops, and their associated functionalities. Additionally, it highlights the differences between control structures like switch and if, and explains how to jump out of loops using break and continue statements.
control_structures_c_language_regarding how to represent the loop in language...ShirishaBuduputi
The document outlines control statements in the C programming language, categorizing them into sequential, conditional (decision), and iteration (loop) controls. It details various constructs such as if statements, while loops, for loops, switch-case statements, and break/continue statements, each accompanied by example code to illustrate their usage. Additionally, it explains the conditional operator and the purpose of jump statements, providing a comprehensive overview of controlling program flow in C.
Managing input and output operations & Decision making and branching and loopingletheyabala
The document explains various input and output operations in C programming, including the syntax and examples of switch statements, conditional (ternary) operators, and goto statements. It also covers loop structures such as while, do...while, and for loops, detailing their syntax and operational behavior. Each loop type is illustrated with example code demonstrating their use in practical scenarios.
The document explains input and output functions in C, specifically the usage of printf() and scanf() for displaying and reading data. It also covers control flow structures including if-else statements, switch statements, and different types of loops such as while, do-while, and for loops, along with their functionalities and syntax. Additionally, it introduces control statements like break, continue, and goto for managing program execution flow.
Chapter 3 covers control flow structures in C programming, focusing on decision-making statements like 'if', 'if...else', and 'switch...case' statements. It also explains loop constructs including 'for', 'while', and 'do...while' loops, along with 'break' and 'continue' statements, which manage loop execution. Additionally, it discusses the 'goto' statement for altering program control flow.
Fundamental of Information Technology - UNIT 8Shipra Swati
This document discusses different types of control structures in C programming including sequence control, selection/decision control, case control, and repetition/loop control. It provides examples of if, if-else, switch, for, and while loops. The if statement and if-else statement are used for decision making and branching based on a condition being true or false. Switch statements provide an alternative for nested if-else statements. Loops like for and while are used to repeat a block of code until a condition is met. Examples are given to calculate the sum of natural numbers using for and while loops.
control-statements, control-statements, control statementcrrpavankumar
The document provides an overview of control flow statements in C programming, highlighting decision control statements such as if, if-else, and switch, as well as looping structures like while, do-while, and for loops. It explains the syntax and use cases for each control structure, including examples of code implementing these constructs. Additionally, it discusses the use of break, continue, goto statements, and the exit() function for controlling program execution flow.
The document discusses various control structures and functions used in Arduino programming including decision making structures like if, else if, else statements and switch case statements. It also covers different types of loops like while, do-while and for loops that allow repeating blocks of code. Functions are described as reusable blocks of code that perform tasks and help organize a program. Strings can be implemented as character arrays or using the String class, and various string functions are provided to manipulate and work with strings.
The document provides an introduction to programming in C and explains key concepts like variables, input/output, control structures (if/else, for loops, do-while loops), and switch statements through examples. It defines variables as locations for temporarily storing values, describes how the scanf function is used for input and printf for output, and explains how control structures like if/else and loops allow conditional or repeated execution of code. The examples given illustrate how each concept works in a C program.
Btech i pic u-3 handling input output and control statementsRai University
The document discusses various control statements in C programming language including if-else statements, switch statements, loops (while, do-while, for loops), and jump statements like break, continue, goto. It provides examples of each statement and explains their usage and flow. Key control statements covered are if-else, switch, while, do-while, for loops, break, continue. Nested control structures and their flow is also explained with examples.
Diploma ii cfpc u-3 handling input output and control statementsRai University
This document discusses control statements and looping in the C programming language. It covers if-else statements, switch statements, the ternary operator, goto statements, while loops, do-while loops, for loops, and nested loops. It provides examples of each construct and describes how they control program flow. Jump statements like break and continue are also covered, allowing programs to exit or skip parts of loops.
The document discusses various control statements in C programming including selection statements like if, if-else, switch and iteration statements like for, while, do-while. It explains how to use these statements to control program flow through conditional execution and selection. Some key concepts covered include nested if statements, the dangling else problem, switch vs if-else statements, testing equality in loops, and using break, continue and goto statements. The document also provides examples of using control statements to find the largest of three numbers and calculate a factorial.
The document discusses various control statements in C programming including selection statements like if, if-else, switch and iteration statements like for, while, do-while. It explains how to use these statements to control program flow through conditional execution and selection. Some key concepts covered include nested if statements, the dangling else problem, switch vs if-else statements, testing floating point equality in loops, and using break and continue statements. The document also provides examples of various control structures like if-else ladder, nested loops and using goto statements.
Mca i pic u-3 handling input output and control statementsRai University
The document discusses various control statements in C programming language including if-else statements, switch statements, loops (while, do-while, for loops), and jump statements like break, continue, goto. It provides examples of each statement type and explains their usage and flow. Key control statements covered are if-else, switch, while, do-while, for loops, and how to exit or continue within loops using break, continue and goto statements.
handling input output and control statementsRai University
The document discusses various control statements in C programming language including if-else statements, switch statements, loops (while, do-while, for loops), and jump statements like break, continue, goto. It provides examples of each statement and explains their usage and flow. Key control statements covered are if-else, switch, while, do-while, for loops, break, continue. Nested control structures and their flow is also explained with examples.
Loops in C are used to execute a block of code repeatedly until a specified condition is met, allowing for more efficient coding by reducing the number of lines required. There are three types of loops: while, for, and do-while, each with distinct structures and uses. While loops check the condition before executing, for loops allow more control with initialization and increments, and do-while loops ensure the body executes at least once before checking the condition.
Loops in C are constructs that allow a set of statements to be executed repeatedly until a specified condition is met, resulting in code efficiency and ease in managing repetitive tasks. There are three main types of loops in C: while loop, for loop, and do-while loop, each functioning in slightly different ways with specific syntax. Additionally, infinite loops can occur if the conditions for termination are not properly defined.
The document discusses control statements in C programming, focusing on how they dictate the execution order of instructions. It covers various types, including sequence, decision, case, and loop statements, with particular emphasis on if-else, switch statements, and three types of loops: for, while, and do-while. Additionally, it highlights the use of continue, exit, and goto statements for controlling program flow.
The document summarizes common repetition structures in C programming including while, do-while, for loops as well as break, continue, and exit statements. It explains that repetition structures allow code to execute repeatedly while a condition is true and covers the syntax and usage of each structure.
Bsc cs pic u-3 handling input output and control statementsRai University
The document discusses various control statements in C programming language including if-else statements, switch statements, loops (while, do-while, for loops), and jump statements like break, continue, and goto. It provides examples of each statement type and explains their usage and flow. Key control statements covered are if-else, switch, while, do-while, for loops, and how to exit or continue within loops using break, continue and goto statements.
The document discusses decision-making in C programming, covering various constructs such as if statements, switch statements, conditional operators, and goto statements. It explains the usage, syntax, and examples for each construct, as well as loops in C, including while, for, and do-while loops, and their associated functionalities. Additionally, it highlights the differences between control structures like switch and if, and explains how to jump out of loops using break and continue statements.
control_structures_c_language_regarding how to represent the loop in language...ShirishaBuduputi
The document outlines control statements in the C programming language, categorizing them into sequential, conditional (decision), and iteration (loop) controls. It details various constructs such as if statements, while loops, for loops, switch-case statements, and break/continue statements, each accompanied by example code to illustrate their usage. Additionally, it explains the conditional operator and the purpose of jump statements, providing a comprehensive overview of controlling program flow in C.
Managing input and output operations & Decision making and branching and loopingletheyabala
The document explains various input and output operations in C programming, including the syntax and examples of switch statements, conditional (ternary) operators, and goto statements. It also covers loop structures such as while, do...while, and for loops, detailing their syntax and operational behavior. Each loop type is illustrated with example code demonstrating their use in practical scenarios.
The document explains input and output functions in C, specifically the usage of printf() and scanf() for displaying and reading data. It also covers control flow structures including if-else statements, switch statements, and different types of loops such as while, do-while, and for loops, along with their functionalities and syntax. Additionally, it introduces control statements like break, continue, and goto for managing program execution flow.
Chapter 3 covers control flow structures in C programming, focusing on decision-making statements like 'if', 'if...else', and 'switch...case' statements. It also explains loop constructs including 'for', 'while', and 'do...while' loops, along with 'break' and 'continue' statements, which manage loop execution. Additionally, it discusses the 'goto' statement for altering program control flow.
Fundamental of Information Technology - UNIT 8Shipra Swati
This document discusses different types of control structures in C programming including sequence control, selection/decision control, case control, and repetition/loop control. It provides examples of if, if-else, switch, for, and while loops. The if statement and if-else statement are used for decision making and branching based on a condition being true or false. Switch statements provide an alternative for nested if-else statements. Loops like for and while are used to repeat a block of code until a condition is met. Examples are given to calculate the sum of natural numbers using for and while loops.
control-statements, control-statements, control statementcrrpavankumar
The document provides an overview of control flow statements in C programming, highlighting decision control statements such as if, if-else, and switch, as well as looping structures like while, do-while, and for loops. It explains the syntax and use cases for each control structure, including examples of code implementing these constructs. Additionally, it discusses the use of break, continue, goto statements, and the exit() function for controlling program execution flow.
Paired Sketching of Distributed User Interfaces:Workflow, Protocol, Software ...Jean Vanderdonckt
Paper présented at ACM EICS '25:
The evolving landscape of distributed user interfaces requires the prototyping stage also be distributed between users, tasks, platforms, and environments. To create a cohesive distribution of the user interface elements in such ecosystems, paired sketching has emerged as a collaborative design method that leverages multiple stakeholders’ strengths, including designers, developers, and end users, working in pairs. In the context of developer experience applied to paired sketching for distributed
user interfaces, we decomposed a workflow into four disciplines according to the Software and Systems Process Engineering
Meta-Model (SPEM) notation. First, we defined a protocol to deploy paired sketching of distributed user interfaces, supported
by UbiSketch, a collaborative software environment tailored featuring sketch recognition and whiteboarding. Second, to
evaluate paired sketching for engineering interactive systems, we conducted an experiment involving five pairs of stakeholders
who sketched a distributed user interface for inside-the-vehicule interaction distributed on four platforms: smartphone, tablet, pen display, and tabletop. Empirical results from questionnaires, reactivity, intention, perceived satisfaction, and free comments, suggest a preference order in which the tabletop is ranked first, followed by the tablet, smartphone, and pen display. Based on these results, we discuss the potential of paired sketching for distributed user interfaces.
SULFUR PEARL OF NAMIBIA - Thiomargarita namibiensisaparnamp966
This document explores the fascinating discovery and ecological significance of Thiomargarita namibiensis, known as the "Sulfur Pearl of Namibia"—the largest bacterium ever found. Discovered in 1999 by researchers from the Max Planck Institute, this bacterium thrives in sulfur-rich environments like Walvis Bay, Namibia. Despite sulfur’s toxicity, T. namibiensis plays a crucial role in detoxifying the marine habitat by oxidizing harmful hydrogen sulfide using internally stored nitrate. The bacterium’s ability to store nitrate at concentrations 10,000 times higher than seawater and survive in extreme conditions makes it ecologically vital and a subject of interest for evolutionary research and potential future biotechnological applications. The document emphasizes its environmental role, potential for space-related anaerobic survival, and the challenge of cultivating it in lab settings.
Author: Aparna M P
MOLD -GENERAL CHARACTERISTICS AND CLASSIFICATIONaparnamp966
This is a brief note on types of organism on food with special focus on molds. This includes their general characteristics, spores; their classification, mycotoxins, and how the molds affect food.
Study of Appropriate Information Combination in Image-based Obfuscated Malwar...takahashi34
This slide introduces our study titled "Study of Appropriate Information Combination in Image-based Obfuscated Malware Detection", which was presented at DSN2025.
To tackle the threat of obfuscated malware, our study proposes an image-based detection method that combines four types of information—byte values, entropy, semantic information, and bigrams frequency—from Windows PE executable files. Proposed method is evaluated in a realistic environment containing both obfuscated and non-obfuscated benign and malicious files. Evaluation results show that combining these information types achieves 88.66% accuracy, demonstrating the effectiveness of information combination for detecting obfuscated malware.
An Analysis Of The Pearl Short Story By John SteinbeckBillyDarmawan3
John Steinbeck Popular Short Story
The Pearl adalah sebuah novella yang ditulis oleh John Steinbeck yang mengisahkan perjuangan seorang nelayan miskin bernama Kino dan istrinya, Juana, yang hidup sederhana di sebuah desa kecil Meksiko. Suatu hari, Kino menemukan sebuah mutiara raksasa — "the Pearl of the World" — yang diyakini akan mengubah nasib mereka.
Namun, alih-alih membawa kebahagiaan, mutiara itu justru menimbulkan keserakahan, kekerasan, dan penderitaan. Masyarakat di sekitarnya mulai menunjukkan niat jahat, dan bahkan keluarga Kino sendiri terjebak dalam konflik batin antara harapan dan kehancuran. Pada akhirnya, The Pearl menjadi simbol ironi: sesuatu yang tampak sebagai berkah berubah menjadi kutukan.
Melalui cerita ini, Steinbeck mengeksplorasi tema keserakahan, harapan, kemiskinan, dan ketimpangan sosial. Dengan gaya narasi yang lugas namun penuh makna simbolik, The Pearl menjadi refleksi tajam tentang sifat manusia dan dampak tragis dari keinginan yang tak terkendali.
How Psychology Can Power Product Decisions: A Human-Centered Blueprint- Shray...ShrayasiRoy2
In an era where users are bombarded with endless choices, capturing attention and driving meaningful engagement isn't just about building features — it's about understanding what drives human behavior at its core. This presentation offers a deep dive into how psychological principles can inform smarter, more intuitive product decisions. It’s not just theory — it’s a hands-on blueprint for applying human-centered thinking at every stage of product development.
Grounded in behavioral science, consumer psychology, and cognitive design, this deck unpacks the key psychological drivers behind user motivation, decision-making, emotional engagement, and habit formation. From attention economics and dopamine-driven interactions to trust cues, loss aversion, and the paradox of choice — you'll see how to harness what the mind naturally does to build digital products people don’t just use… they return to, talk about, and even advocate for.
We’ll explore:
Cognitive biases that shape user perception and choices — and how to use them to your advantage without crossing ethical lines.
Emotional design principles that build trust, trigger desire, and turn features into feelings.
User behavior loops that build stickiness, deepen retention, and create emotional investments.
Psychological friction — when to reduce it for conversion, and when to add it for intentionality.
Dark patterns vs. ethical persuasion — the thin line between influence and manipulation.
A/B testing with a psychological lens — learning not just what works, but why it works.
This is more than UX research or product marketing fluff. It’s a call to build with empathy, backed by science, and sharpened by real-world product thinking. Whether you’re shaping onboarding flows, gamifying engagement, designing pricing models, or rethinking retention strategies — this deck will arm you with a new lens: the human mind.
Perfect for product managers, growth strategists, UX designers, behavioral scientists, and anyone serious about building products that resonate, retain, and inspire action.
Because at the heart of every great product… is a human.
Let’s start building for the brain — not just the screen.
Excipients can be defined as non active ingredients that are mixed with therapeutically active compounds to form medicines. The excipients are the substance which are used as a medium for giving a medicament.These help in processing of the drug delivery system during its manufacture, protect, support or enhance stability, bioavailability or patient acceptability.
The word comes from the Latin word meaning a sweets melling fluid contain the essence of flowers and other substances. Perfume is a mixture of fragrant essential oil and aroma compounds Fragrances used for external applications such as spray perfumes, body care, homecare, cosmetics, soaps and detergents.
2. 2
Conditional operators in details
Decision making structures like IF, IF-ELSE
AND SWITCH
Loop control structures like FOR, WHILE, DO-
WHILE
Implementation of break and continue.
Nested structures.
Unconditional branching (GOTO statement).
3. 3
INTRODUCTION:-
Normally the statement of a program are
executed from first to last.
Sometimes it is necessary to alter the sequence of
execution of statements.
Based on certain conditions or we may require
some statements to be executed repeatedly until
some condition is satisfied.
This involves decision making and looping.
4. 4
THREE MECHANISM ARE:-
if statement:Many program we require testing
of some condition at some point in the program
and take action.
Syntax: if(condition)
{
Statements;
}
Expressio
n
statements
F
T
5. 5
if-else statement:Many program require testing of
some condition at some point in the program and
selecting one of the alternative at some point and
selecting one of the alternative path depending upon
the result is known as branching.
General Form is:
if(expression)
statement1 ;
else
statement 2;
Expressi
on
statement1 statement2
T F
6. 6
Ex. Check given number is even or odd. Example of if-else
statement
Solution:
#include<stdio.h>
main( )
{
int no;
printf(“n Enter any number”);
scanf(“%d”,&no);
if (no %2==0)
{
printf(“ number=%d is even number”,no);
}
else
{
printf(“n number =%d is odd number”,no);
}
}//main
7. 7
NESTED IF–ELSE STATEMENT
NESTED “IF-ELSE” STATEMENTS:-
Nested “if-else” statements, the if or the else can
contain another if or if-else statement. This provides a
programmer with a lot of flexibility in programming.
Nesting could take one of several form as illustrated as
below:
1] if statement inside else:-
Syntax: if(expression)
Statement1;
else
if(expression2)
Statement2;
9. 9
4] if-else statement inside if-else:-
Syntax:-if(expression1)
{if(expression2)
statement1;
else
statement 2;}
else
if(expression3)
statement3;
else
statement 4;
Eg Write a c program to accept 3 no from user and check greater no.
#include<stdio.h>
#include<conio.h>
void main()
{
int no1, no2, no3;
clrscr();
printf(“n Ennter any 3 nos:”);
scanf(“%d%d%d”,&no1,&no2,&no3);
if(no1>no2)
if(no1>no3)
printf(“n no1 is greater number”);
10. 10
5]else-if ladder:-
If there is if-else statement nested in each else
of an if-else construct, that is called as else-if ladder.
Syntax: if(expression1)
statement 1;
else
if(expression 2)
statement2;
else
if(expression3)
statement 3;
else
statement 4;
11. 11
Conditional Branching switch Statement:
Whenever we want to make decision among
multiple alternatives nested else-if statement can
be used, however structure become very
complicated and code become difficult to read and
trace. For this reason C has a build-in multi
branch decision statement called switch.
case 1 value 1
switch(expr) case 2 value 2
case n value n
default
12. 12
RULES:-
Syntax:
switch(expression)
{
case value1: Statements;
break;
case value 2: Statements;
break;
….
case value n: Statements;
break;
default : Statements;
}
The expression enclosed within parenthesis is successively compare
against the constant expression(value)in each case. They called case
labeled and must be end with colon( : ).
The statement in each case may contain zero or more statements. If there
are multiple statement for a case they need not be enclosed in bracket.
All case expression must be different.
The case default is executed if non of the other case match.
13. 13
NESTED SWITCH STATEMENT:-
It is possible to have a switch statement
as a part of statement is another switch
statement then it is called as Nested
switch statement.
Even if the case constant of the inner and
outer switch contain common values there
is not conflict.(mix with each other)
14. 14
Ex.
#include<stdio.h>
main()
{
int x,y;
printf(“n enter 2 binary values”);
scanf(“%d%d”,&x,&y);
switch(x)
{
case 0:printf(“n Invalid Values”);
break;
case 1: switch(y)
{
case 0: printf(“n Values are 1 & 0”);
break;
case 1:printf(“n Values are 1 & 1”);
break;
}// inner switch
break;
} //outer switch
}//main
15. 15
LOOP CONTROL STRUCTURE:-
A block of program statements that is executed
repeatedly is called a loop. The repetition is done
until some condition for termination of the loop is
satisfied .
A loop structure essentially contains a test
condition.
1]A test condition determines the number of times
the loop body is executed.
2]Loop statements- If the test condition evaluate to
true then statement within the loop body get
executed otherwise control transfer outside the
loop i.e loop termination.
initially contains a test condition.
16. 16
1) Top –Tested Loop:
An Entry Controlled loop , the condition is evaluated before the loop
body is executed. Ex.while,for
Test
Condition
Loop Body Statement
False
True
17. 17
2) Bottom tested loop(exit controlled loop).
In exit controlled loop, the condition is tested after
the loop body executed.
Ex.do-while
Loop Body
Test
Condition
True
False
18. 18
ITERATION PROCEDURE:-
The iteration procedure takes place in 4 steps
1. Initializing the loop control variable.
2. Execution of loop statement.
3. Changing the value of the control variable.
4. Testing the condition.
5. The C language provides 3 loops:-
6. 1) while
7. 2) do-while
8. 3) for
19. 19
LOOPS:-
C LANGUAGE PROVIDES 3 LOOP
STRUCTURES:-
1) While: It is often used when the no. of time the
loop is to be executed is not known in advanced
but depends on the test condition.ENTRY
CONTOL LOOP
2) do-while: do-while loop is a bottom tested or
exit controlled loop i.e it evaluates the condition
after the execution of statement in it construct.
This means that the statements within the loop
are executed at least once if the condition is false.
3) for: for loop is very flexible, powerful and most
commonly used loop in C. It is useful when the
member of repetition is known in advance. This is
a top-tested loop similarly to the while loop.
20. 20
1] While:-
It is often used when the no. of time the
loop is to be executed is not known in
advanced but depends on the test condition.
Syntax:- while(expression)
{
statements;
}
That expression is a test condition and can
be any valid c expression. The statement can
be a single or set of statement.
21. 21
2) The do-while loop
Iterative statement means loop control statement.
do-while loop, is a bottom-tested or exit control
loop i.e. It evaluates the condition after the
execution of statements in its.
This means that the statements within the loop
are executed at-least once, when condition is false.
Syntax:
do
{
statements;
}while(expression);
22. 22
3] for loop:-
For loop is very flexible, powerful and most
commonly used loop in C . It is useful when the
member of repetition is known in advance.
This is a top-tested loop similarly to the while loop.
Syntax:-
for(exp1;exp2;exp3) ex. for( i=1;i<=10;i++)
{
statement;
}
Where, expr1 is to used to initialization of expression.
expr2 is used to test condition .
expr3 is used to update expression.
these 3 expression is separated by ‘ ; ’.
23. 23
Eg. Write a program to print first 10 no’s
using for loop
#include<stdio.h>
void main()
{
int i;
for(i=1;i<=10;i=i+1)
{
printf(“%d”,i);
}
}
24. 24
Print table for the given number using C for loop
#include<stdio.h>
int main()
{
int i=1,number=0;
printf("Enter a number: ");
scanf("%d",&number);
for(i=1;i<=10;i++)
{
printf("%d n",(number*i));
}
return 0;
}
28. 28
NESTED LOOP:-
Loop can also be nested ,Nesting of loops means a loop i.e contain within another loop. Any loop can be nested
within any other loop.
Eg:
1) while(expr1)
{
while(expr2)
{
loop body of inner while
}
}
2) while(expr1)
{
for( )
{
loop body of for
}
}
3) for( )
{
…….
for( )
{
statements;
}
}
29. 29
#include <stdio.h>
int main()
{
int n;// variable declaration
printf("Enter the value of n :");
// Displaying the n tables.
for(int i=1;i<=n;i++) // outer loop
{
for(int j=1;j<=10;j++) // inner loop
{
printf("%dt",(i*j)); // printing the value.
}
printf("n");
}
30. 30
#include <stdio.h>
int main()
{
int rows; // variable declaration
int columns; // variable declaration
int k=1; // variable initialization
printf("Enter the number of rows :"); // input the number of rows.
scanf("%d",&rows);
printf("nEnter the number of columns :"); // input the number of columns.
scanf("%d",&columns);
int a[rows][columns]; //2d array declaration
int i=1;
while(i<=rows) // outer loop
{
int j=1;
while(j<=columns) // inner loop
{
printf("%dt",k); // printing the value of k.
k++; // increment counter
j++;
}
i++;
printf("n");
}
}
32. 32
JUMP STATEMENT:-
In many cases we want to stop the execution loop
before it ends or transfer the control to some
other part of a program. This can be done using
jump statement.
C supports 4 jump statements
1. break
2. continue
3. return
4. Goto
5. exit
33. 33
1] break:-
Sometime it is require to exit a loop as soon as a
certain condition is made.
To skip all subsequent statement of loop body and to come
out of the loop.
When the break statement is encounter inside a loop, the
loop is immediately terminate subsequent statement are
skipped and program control transfer at the next
statement of the following loop.
36. 36
#include <stdio.h>
int main() {
int n, i, flag = 0;
printf("Enter a positive integer: ");
scanf("%d", &n);
// 0 and 1 are not prime numbers
// change flag to 1 for non-prime number
if (n == 0 || n == 1)
flag = 1;
for (i = 2; i <= n / 2; ++i) {
// if n is divisible by i, then n is not prime
// change flag to 1 for non-prime number
if (n % i == 0) {
flag = 1;
break;
}
}
// flag is 0 for prime numbers
if (flag == 0)
printf("%d is a prime number.", n);
else
printf("%d is not a prime number.", n);
return 0;
}
38. 38
2]continue:-
Continue statement is used to transfer control
to the beginning of the loop.
It remaining statement and it forces the next
interaction of the loop to takes place as usual.
Syntax:- continue;
41. 41
In this program the loop generates 1 to 10 values of the variable "i".
Whenever it is an even number, the next iteration starts, skipping the printf
statement. Only the odd numbers are printed.
#include <stdio.h>
int main(){
int i = 0;
while (i < 10){
i++;
if(i%2 == 0)
continue;
printf("i: %dn", i);
}
}
Output
i: 1
i: 3
i: 5
i: 7
i: 9
42. 42
3] goto Statement:-
goto statement is an unconditional jump
statement.
Goto statement is use to alter the normal sequence of
program execution by unconditionally transferring by
control some other part of program.
Syntax: goto label;
The statement where control has to be transfer is
identified by the label.
A label is valid C identifier.
The label followed by colon “:” .
The label can attached to any statement in the same
function as the goto.
The label does not has to be declared like other identifier.
45. 45
#include <stdio.h>
int main (){
int n = 0;
if (n == 0)
goto end;
printf("The number is: %d", n);
end:
printf ("End of program");
return 0;
}
46. 46
#include <stdio.h>
int main (){
START:
printf("Hello World n");
printf("How are you? n");
goto START;
return 0;
}
Output:
Hello World
How are you?
.......
.......
The program prints the two strings continuously until
forcibly stopped.
47. 47
4] exit():-
The exit(0) function causes indicate
termination of the entire program .the exit
function is called with an arguments’0’ to
indicate that termination is normal.
Eg. Invalid password enter that time use exit(0).