SlideShare a Scribd company logo
Control Statements and
Functions in C
V.V.Subrahmanyam,
Sr. Lecturer,
SOCIS, IGNOU
Date: 04-02-07
Time: 1-00 to 1-45
Control Statements
Branching:
 The if statement
 If – Else statement
Looping:
 While Statement
 Do-while statement
 For Statement
Switch statement
If statement
If (expr) statement
Example: if (x<0)
printf (“ %d”, x);
If – else statement
If (expr) statement1;
else
statement2;
Example:
if (status == ‘s”)
tax = 0.20 * pay;
else
tax = 0.14 * pay;
Nested if - else
if e1 if e2 s1
else s2
else if e3 s3
else s4
While statement
while (expr)
{ statement(s); }
Example: int digit=9;
while(digit <= 9)
{
printf(“%dn”, digit);
++digit;
}
Do – while statement
Do statement while (expr);
Example:
{
int digit = 10;
do
printf(“%dn”, digit);
while (digit <= 9);
}
For loop
For (expr1; expr2; expr3) statement
Example:
int I;
for (i=0;i<=10; i++) {
printf(“%d”, i);
}
Break statement
It can be used within a for, while , do-
while, or a switch statement.
It is used to terminate a loop or to exit
from a switch statement in a convenient
way when a condition is met, if any
error or irregular condition is detected.
Continue statement
It is used to bypass the remainder of the
current pass through a loop. The loop
does not terminate when a continue
statements is encountered. Rather, the
remaining loop statements are skipped
and the computation proceeds directly
to the next pass through the loop.
Goto statement
The goto statement is used to alter the normal
sequence of program execution by
transferring control to some other part of the
program.
goto label;
---
---
Label: statement;
Functions
The use of user-defined functions
allows a large program to be broken
down into a number of smaller, self-
contained components, each of which
has some unique, identifiable purpose.
The C program can be modularized
through the intelligent use of such
functions.
Avoids the need of repeated
programming of the same instructions.
Types of functions
Functions with no parameters and no
return value
Functions with parameters and no
return value
Functions with parameters and with
return value.
Function Declaration
Prototype declaration at the declaration
part.
Data-type fname(type1 arg1, type2 arg2);
Function definition
Actual statements of the function to
solve the specified task.

More Related Content

What's hot

C++ programming Unit 5 flow of control
C++ programming Unit 5 flow of controlC++ programming Unit 5 flow of control
C++ programming Unit 5 flow of controlAAKASH KUMAR
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c languagetanmaymodi4
 
C++ decision making
C++ decision makingC++ decision making
C++ decision makingZohaib Ahmed
 
Unit II chapter 4 Loops in C
Unit II chapter 4 Loops in CUnit II chapter 4 Loops in C
Unit II chapter 4 Loops in CSowmya Jyothi
 
Control and conditional statements
Control and conditional statementsControl and conditional statements
Control and conditional statementsrajshreemuthiah
 
COM1407: Program Control Structures – Repetition and Loops
COM1407: Program Control Structures – Repetition and Loops COM1407: Program Control Structures – Repetition and Loops
COM1407: Program Control Structures – Repetition and Loops Hemantha Kulathilake
 
[ITP - Lecture 10] Switch Statement, Break and Continue Statement in C/C++
[ITP - Lecture 10] Switch Statement, Break and Continue Statement in C/C++[ITP - Lecture 10] Switch Statement, Break and Continue Statement in C/C++
[ITP - Lecture 10] Switch Statement, Break and Continue Statement in C/C++Muhammad Hammad Waseem
 
Elements of c program....by thanveer danish
Elements of c program....by thanveer danishElements of c program....by thanveer danish
Elements of c program....by thanveer danishMuhammed Thanveer M
 
Decision making statements in C programming
Decision making statements in C programmingDecision making statements in C programming
Decision making statements in C programmingRabin BK
 
C Programming: Control Structure
C Programming: Control StructureC Programming: Control Structure
C Programming: Control StructureSokngim Sa
 
Selection Statements in C Programming
Selection Statements in C ProgrammingSelection Statements in C Programming
Selection Statements in C ProgrammingKamal Acharya
 
Decision Making Statement in C ppt
Decision Making Statement in C pptDecision Making Statement in C ppt
Decision Making Statement in C pptMANJUTRIPATHI7
 
Types of loops in c language
Types of loops in c languageTypes of loops in c language
Types of loops in c languagesneha2494
 

What's hot (19)

C++ programming Unit 5 flow of control
C++ programming Unit 5 flow of controlC++ programming Unit 5 flow of control
C++ programming Unit 5 flow of control
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c language
 
Control structure in c
Control structure in cControl structure in c
Control structure in c
 
C++ decision making
C++ decision makingC++ decision making
C++ decision making
 
Unit II chapter 4 Loops in C
Unit II chapter 4 Loops in CUnit II chapter 4 Loops in C
Unit II chapter 4 Loops in C
 
Control structures in c
Control structures in cControl structures in c
Control structures in c
 
Control and conditional statements
Control and conditional statementsControl and conditional statements
Control and conditional statements
 
Controls & Loops in C
Controls & Loops in C Controls & Loops in C
Controls & Loops in C
 
COM1407: Program Control Structures – Repetition and Loops
COM1407: Program Control Structures – Repetition and Loops COM1407: Program Control Structures – Repetition and Loops
COM1407: Program Control Structures – Repetition and Loops
 
Control structures in C
Control structures in CControl structures in C
Control structures in C
 
[ITP - Lecture 10] Switch Statement, Break and Continue Statement in C/C++
[ITP - Lecture 10] Switch Statement, Break and Continue Statement in C/C++[ITP - Lecture 10] Switch Statement, Break and Continue Statement in C/C++
[ITP - Lecture 10] Switch Statement, Break and Continue Statement in C/C++
 
Elements of c program....by thanveer danish
Elements of c program....by thanveer danishElements of c program....by thanveer danish
Elements of c program....by thanveer danish
 
Decision making statements in C programming
Decision making statements in C programmingDecision making statements in C programming
Decision making statements in C programming
 
Control statements
Control statementsControl statements
Control statements
 
C Programming: Control Structure
C Programming: Control StructureC Programming: Control Structure
C Programming: Control Structure
 
[ITP - Lecture 11] Loops in C/C++
[ITP - Lecture 11] Loops in C/C++[ITP - Lecture 11] Loops in C/C++
[ITP - Lecture 11] Loops in C/C++
 
Selection Statements in C Programming
Selection Statements in C ProgrammingSelection Statements in C Programming
Selection Statements in C Programming
 
Decision Making Statement in C ppt
Decision Making Statement in C pptDecision Making Statement in C ppt
Decision Making Statement in C ppt
 
Types of loops in c language
Types of loops in c languageTypes of loops in c language
Types of loops in c language
 

Similar to Introduction to C Programming

C UNIT-2 PREPARED Y M V BRAHMANANDA REDDY
C UNIT-2 PREPARED Y M V BRAHMANANDA REDDYC UNIT-2 PREPARED Y M V BRAHMANANDA REDDY
C UNIT-2 PREPARED Y M V BRAHMANANDA REDDYRajeshkumar Reddy
 
C language UPTU Unit3 Slides
C language UPTU Unit3 SlidesC language UPTU Unit3 Slides
C language UPTU Unit3 SlidesRakesh Roshan
 
2. Control structures with for while and do while.ppt
2. Control structures with for while and do while.ppt2. Control structures with for while and do while.ppt
2. Control structures with for while and do while.pptManojKhadilkar1
 
Control Structures in C
Control Structures in CControl Structures in C
Control Structures in Csana shaikh
 
Fundamental of Information Technology - UNIT 8
Fundamental of Information Technology - UNIT 8Fundamental of Information Technology - UNIT 8
Fundamental of Information Technology - UNIT 8Shipra Swati
 
C Programming Language Part 6
C Programming Language Part 6C Programming Language Part 6
C Programming Language Part 6Rumman Ansari
 
computer programming and utilization
computer programming and utilizationcomputer programming and utilization
computer programming and utilizationJAYDEV PATEL
 
INPUT AND OUTPUT STATEMENTS IN PROGRAMMING IN C
INPUT AND OUTPUT STATEMENTS IN PROGRAMMING IN CINPUT AND OUTPUT STATEMENTS IN PROGRAMMING IN C
INPUT AND OUTPUT STATEMENTS IN PROGRAMMING IN CChandrakant Divate
 
C lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshareC lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshareGagan Deep
 
C statements.ppt presentation in c language
C statements.ppt presentation in c languageC statements.ppt presentation in c language
C statements.ppt presentation in c languagechintupro9
 
Introduction to computer programming (C)-CSC1205_Lec5_Flow control
Introduction to computer programming (C)-CSC1205_Lec5_Flow controlIntroduction to computer programming (C)-CSC1205_Lec5_Flow control
Introduction to computer programming (C)-CSC1205_Lec5_Flow controlENGWAU TONNY
 
Object oriented programming system with C++
Object oriented programming system with C++Object oriented programming system with C++
Object oriented programming system with C++msharshitha03s
 

Similar to Introduction to C Programming (20)

C Programming Unit-2
C Programming Unit-2C Programming Unit-2
C Programming Unit-2
 
C UNIT-2 PREPARED Y M V BRAHMANANDA REDDY
C UNIT-2 PREPARED Y M V BRAHMANANDA REDDYC UNIT-2 PREPARED Y M V BRAHMANANDA REDDY
C UNIT-2 PREPARED Y M V BRAHMANANDA REDDY
 
C language UPTU Unit3 Slides
C language UPTU Unit3 SlidesC language UPTU Unit3 Slides
C language UPTU Unit3 Slides
 
2. Control structures with for while and do while.ppt
2. Control structures with for while and do while.ppt2. Control structures with for while and do while.ppt
2. Control structures with for while and do while.ppt
 
Control Structures in C
Control Structures in CControl Structures in C
Control Structures in C
 
C fundamental
C fundamentalC fundamental
C fundamental
 
Fundamental of Information Technology - UNIT 8
Fundamental of Information Technology - UNIT 8Fundamental of Information Technology - UNIT 8
Fundamental of Information Technology - UNIT 8
 
C Programming Language Part 6
C Programming Language Part 6C Programming Language Part 6
C Programming Language Part 6
 
computer programming and utilization
computer programming and utilizationcomputer programming and utilization
computer programming and utilization
 
Session 3
Session 3Session 3
Session 3
 
INPUT AND OUTPUT STATEMENTS IN PROGRAMMING IN C
INPUT AND OUTPUT STATEMENTS IN PROGRAMMING IN CINPUT AND OUTPUT STATEMENTS IN PROGRAMMING IN C
INPUT AND OUTPUT STATEMENTS IN PROGRAMMING IN C
 
C lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshareC lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshare
 
C statements.ppt presentation in c language
C statements.ppt presentation in c languageC statements.ppt presentation in c language
C statements.ppt presentation in c language
 
C programming session3
C programming  session3C programming  session3
C programming session3
 
C programming session3
C programming  session3C programming  session3
C programming session3
 
Introduction to computer programming (C)-CSC1205_Lec5_Flow control
Introduction to computer programming (C)-CSC1205_Lec5_Flow controlIntroduction to computer programming (C)-CSC1205_Lec5_Flow control
Introduction to computer programming (C)-CSC1205_Lec5_Flow control
 
Control statments in c
Control statments in cControl statments in c
Control statments in c
 
Elements of programming
Elements of programmingElements of programming
Elements of programming
 
Object oriented programming system with C++
Object oriented programming system with C++Object oriented programming system with C++
Object oriented programming system with C++
 
Ch3 repetition
Ch3 repetitionCh3 repetition
Ch3 repetition
 

More from vampugani

Social media presentation
Social media presentationSocial media presentation
Social media presentationvampugani
 
Creating Quick Response(QR) Codes for the OER
Creating Quick Response(QR) Codes for the OERCreating Quick Response(QR) Codes for the OER
Creating Quick Response(QR) Codes for the OERvampugani
 
Arithmetic Computation using 2's Complement Notation
Arithmetic Computation using 2's Complement NotationArithmetic Computation using 2's Complement Notation
Arithmetic Computation using 2's Complement Notationvampugani
 
Post Graduate Diploma in Computer Applications (PGDCA)
Post Graduate Diploma in Computer Applications (PGDCA)Post Graduate Diploma in Computer Applications (PGDCA)
Post Graduate Diploma in Computer Applications (PGDCA)vampugani
 
Overview of Distributed Systems
Overview of Distributed SystemsOverview of Distributed Systems
Overview of Distributed Systemsvampugani
 
Protection and Security in Operating Systems
Protection and Security in Operating SystemsProtection and Security in Operating Systems
Protection and Security in Operating Systemsvampugani
 
Virtual Memory
Virtual MemoryVirtual Memory
Virtual Memoryvampugani
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OSvampugani
 
Process Scheduling
Process SchedulingProcess Scheduling
Process Schedulingvampugani
 
Introduction to OS
Introduction to OSIntroduction to OS
Introduction to OSvampugani
 
Operating Systems
Operating SystemsOperating Systems
Operating Systemsvampugani
 
Distributed Systems
Distributed SystemsDistributed Systems
Distributed Systemsvampugani
 
Multiprocessor Systems
Multiprocessor SystemsMultiprocessor Systems
Multiprocessor Systemsvampugani
 
File Management in Operating Systems
File Management in Operating SystemsFile Management in Operating Systems
File Management in Operating Systemsvampugani
 
Strings in c
Strings in cStrings in c
Strings in cvampugani
 
Introduction to C Programming - I
Introduction to C Programming - I Introduction to C Programming - I
Introduction to C Programming - I vampugani
 

More from vampugani (18)

Social media presentation
Social media presentationSocial media presentation
Social media presentation
 
Creating Quick Response(QR) Codes for the OER
Creating Quick Response(QR) Codes for the OERCreating Quick Response(QR) Codes for the OER
Creating Quick Response(QR) Codes for the OER
 
Arithmetic Computation using 2's Complement Notation
Arithmetic Computation using 2's Complement NotationArithmetic Computation using 2's Complement Notation
Arithmetic Computation using 2's Complement Notation
 
Post Graduate Diploma in Computer Applications (PGDCA)
Post Graduate Diploma in Computer Applications (PGDCA)Post Graduate Diploma in Computer Applications (PGDCA)
Post Graduate Diploma in Computer Applications (PGDCA)
 
Overview of Distributed Systems
Overview of Distributed SystemsOverview of Distributed Systems
Overview of Distributed Systems
 
Protection and Security in Operating Systems
Protection and Security in Operating SystemsProtection and Security in Operating Systems
Protection and Security in Operating Systems
 
Virtual Memory
Virtual MemoryVirtual Memory
Virtual Memory
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OS
 
Process Scheduling
Process SchedulingProcess Scheduling
Process Scheduling
 
Processes
ProcessesProcesses
Processes
 
Introduction to OS
Introduction to OSIntroduction to OS
Introduction to OS
 
Operating Systems
Operating SystemsOperating Systems
Operating Systems
 
Distributed Systems
Distributed SystemsDistributed Systems
Distributed Systems
 
Multiprocessor Systems
Multiprocessor SystemsMultiprocessor Systems
Multiprocessor Systems
 
File Management in Operating Systems
File Management in Operating SystemsFile Management in Operating Systems
File Management in Operating Systems
 
Strings in c
Strings in cStrings in c
Strings in c
 
Arrays in c
Arrays in cArrays in c
Arrays in c
 
Introduction to C Programming - I
Introduction to C Programming - I Introduction to C Programming - I
Introduction to C Programming - I
 

Recently uploaded

Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfDanh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfQucHHunhnh
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfVivekanand Anglo Vedic Academy
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...Jisc
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfTamralipta Mahavidyalaya
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismDeeptiGupta154
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345beazzy04
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsCol Mukteshwar Prasad
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxbennyroshan06
 
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptxJose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptxricssacare
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxJisc
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfkaushalkr1407
 
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptBasic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptSourabh Kumar
 
NLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptxNLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptxssuserbdd3e8
 
Salient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxSalient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxakshayaramakrishnan21
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePedroFerreira53928
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxRaedMohamed3
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxEduSkills OECD
 
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptxSolid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptxDenish Jangid
 
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfINU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfbu07226
 

Recently uploaded (20)

Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfDanh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptxJose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptBasic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
 
NLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptxNLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptx
 
Salient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxSalient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptx
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptxSolid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
 
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfINU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
 

Introduction to C Programming

  • 1. Control Statements and Functions in C V.V.Subrahmanyam, Sr. Lecturer, SOCIS, IGNOU Date: 04-02-07 Time: 1-00 to 1-45
  • 2. Control Statements Branching:  The if statement  If – Else statement Looping:  While Statement  Do-while statement  For Statement Switch statement
  • 3. If statement If (expr) statement Example: if (x<0) printf (“ %d”, x);
  • 4. If – else statement If (expr) statement1; else statement2; Example: if (status == ‘s”) tax = 0.20 * pay; else tax = 0.14 * pay;
  • 5. Nested if - else if e1 if e2 s1 else s2 else if e3 s3 else s4
  • 6. While statement while (expr) { statement(s); } Example: int digit=9; while(digit <= 9) { printf(“%dn”, digit); ++digit; }
  • 7. Do – while statement Do statement while (expr); Example: { int digit = 10; do printf(“%dn”, digit); while (digit <= 9); }
  • 8. For loop For (expr1; expr2; expr3) statement Example: int I; for (i=0;i<=10; i++) { printf(“%d”, i); }
  • 9. Break statement It can be used within a for, while , do- while, or a switch statement. It is used to terminate a loop or to exit from a switch statement in a convenient way when a condition is met, if any error or irregular condition is detected.
  • 10. Continue statement It is used to bypass the remainder of the current pass through a loop. The loop does not terminate when a continue statements is encountered. Rather, the remaining loop statements are skipped and the computation proceeds directly to the next pass through the loop.
  • 11. Goto statement The goto statement is used to alter the normal sequence of program execution by transferring control to some other part of the program. goto label; --- --- Label: statement;
  • 12. Functions The use of user-defined functions allows a large program to be broken down into a number of smaller, self- contained components, each of which has some unique, identifiable purpose. The C program can be modularized through the intelligent use of such functions. Avoids the need of repeated programming of the same instructions.
  • 13. Types of functions Functions with no parameters and no return value Functions with parameters and no return value Functions with parameters and with return value.
  • 14. Function Declaration Prototype declaration at the declaration part. Data-type fname(type1 arg1, type2 arg2);
  • 15. Function definition Actual statements of the function to solve the specified task.