C- language Lecture 4

Lecture 4
C
Language
ENG : HATEM ABD EL-SALAM
• Goto
• Functions
• Recursion
Agenda
Goto
• The goto statement is used to alter the normal sequence of a C
program.
• The label is an identifier. When goto statement is encountered, control
of the program jumps to label: and starts executing the code.
C- language Lecture 4
Goto (Cont.)
Reasons to avoid goto statement
• The use of goto statement may lead to code that is buggy and hard to follow.
For example
• goto statement allows you to do bad stuff such as jump out of scope
• But, goto statement can be useful sometimes. For example: to break from
nested loops.
C- language Lecture 4
C- language Lecture 4
Functions
A function is a block of code that performs a specific task.
Suppose, a program related to graphics needs to create a circle and color
it depending upon the radius and color from the user. You can create two
functions to solve this problem:
• create a circle function
• color function
Dividing complex problem into small components makes program easy to understand
and use.
Functions (Cont.)
• The function form
Functions (Cont.)
• How user-defined function works
Functions (Cont.)
• How to pass argument to function
Functions (Cont.)
• Return statement of function
Functions (Cont.)
Functions (Cont.)
• Keys of Functions:
 It can return one or no values
 It may accept as many parameters it needs or no parameter at all
 After the Function has finished execution. It goes back to the Function that called it
 Function names should be verbs
 Function name is an identifier and should be unique.
Functions (Cont.)
Advantages of function
• The program will be easier to understand, maintain and debug.
• Reusable codes that can be used in other programs
• A large program can be divided into smaller modules. Hence, a large
project can be divided among many programmers.
Recursion
• How recursion works
C- language Lecture 4
Recursion
Advantages of recursion
• Recursion makes program elegant and cleaner. All algorithms can be
defined recursively which makes it easier to visualize and
prove. Reusable codes that can be used in other programs
Disadvantages of recursion
• If the speed of the program is vital then, you should avoid using
recursion. Recursions use more memory and are generally slow
C- language Lecture 4
1 de 19

Recomendados

C- language Lecture 8 por
C- language Lecture 8C- language Lecture 8
C- language Lecture 8Hatem Abd El-Salam
337 visualizações33 slides
C- language Lecture 6 por
C- language Lecture 6C- language Lecture 6
C- language Lecture 6Hatem Abd El-Salam
272 visualizações29 slides
C- language Lecture 5 por
C- language Lecture 5C- language Lecture 5
C- language Lecture 5Hatem Abd El-Salam
407 visualizações26 slides
C- language Lecture 7 por
C- language Lecture 7C- language Lecture 7
C- language Lecture 7Hatem Abd El-Salam
291 visualizações41 slides
Embedded C - Optimization techniques por
Embedded C - Optimization techniquesEmbedded C - Optimization techniques
Embedded C - Optimization techniquesEmertxe Information Technologies Pvt Ltd
30.1K visualizações37 slides
Decision Making & Loops por
Decision Making & LoopsDecision Making & Loops
Decision Making & LoopsAkhil Kaushik
180 visualizações21 slides

Mais conteúdo relacionado

Mais procurados

Code Optimization por
Code OptimizationCode Optimization
Code OptimizationAkhil Kaushik
2.9K visualizações24 slides
Lecture 15 run timeenvironment_2 por
Lecture 15 run timeenvironment_2Lecture 15 run timeenvironment_2
Lecture 15 run timeenvironment_2Iffat Anjum
1.1K visualizações51 slides
Algorithms & Complexity Calculation por
Algorithms & Complexity CalculationAlgorithms & Complexity Calculation
Algorithms & Complexity CalculationAkhil Kaushik
103 visualizações33 slides
Hm system programming class 1 por
Hm system programming class 1Hm system programming class 1
Hm system programming class 1Hitesh Mohapatra
615 visualizações35 slides
Learning New Semi-Supervised Deep Auto-encoder Features for Statistical Machi... por
Learning New Semi-Supervised Deep Auto-encoder Features for Statistical Machi...Learning New Semi-Supervised Deep Auto-encoder Features for Statistical Machi...
Learning New Semi-Supervised Deep Auto-encoder Features for Statistical Machi...Vimukthi Wickramasinghe
570 visualizações10 slides
System Programming Unit III por
System Programming Unit IIISystem Programming Unit III
System Programming Unit IIIManoj Patil
12.5K visualizações42 slides

Mais procurados(20)

Code Optimization por Akhil Kaushik
Code OptimizationCode Optimization
Code Optimization
Akhil Kaushik2.9K visualizações
Lecture 15 run timeenvironment_2 por Iffat Anjum
Lecture 15 run timeenvironment_2Lecture 15 run timeenvironment_2
Lecture 15 run timeenvironment_2
Iffat Anjum1.1K visualizações
Algorithms & Complexity Calculation por Akhil Kaushik
Algorithms & Complexity CalculationAlgorithms & Complexity Calculation
Algorithms & Complexity Calculation
Akhil Kaushik103 visualizações
Hm system programming class 1 por Hitesh Mohapatra
Hm system programming class 1Hm system programming class 1
Hm system programming class 1
Hitesh Mohapatra615 visualizações
Learning New Semi-Supervised Deep Auto-encoder Features for Statistical Machi... por Vimukthi Wickramasinghe
Learning New Semi-Supervised Deep Auto-encoder Features for Statistical Machi...Learning New Semi-Supervised Deep Auto-encoder Features for Statistical Machi...
Learning New Semi-Supervised Deep Auto-encoder Features for Statistical Machi...
Vimukthi Wickramasinghe570 visualizações
System Programming Unit III por Manoj Patil
System Programming Unit IIISystem Programming Unit III
System Programming Unit III
Manoj Patil12.5K visualizações
Workshop Assembler por Tuhin_Das
Workshop AssemblerWorkshop Assembler
Workshop Assembler
Tuhin_Das4.6K visualizações
what is compiler and five phases of compiler por adilmehmood93
what is compiler and five phases of compilerwhat is compiler and five phases of compiler
what is compiler and five phases of compiler
adilmehmood939.2K visualizações
C basics por sridevi5983
C basicsC basics
C basics
sridevi598359 visualizações
Compiler Design Material por Dr. C.V. Suresh Babu
Compiler Design MaterialCompiler Design Material
Compiler Design Material
Dr. C.V. Suresh Babu14.9K visualizações
Intro to Data Structure & Algorithms por Akhil Kaushik
Intro to Data Structure & AlgorithmsIntro to Data Structure & Algorithms
Intro to Data Structure & Algorithms
Akhil Kaushik129 visualizações
Compiler Design Basics por Akhil Kaushik
Compiler Design BasicsCompiler Design Basics
Compiler Design Basics
Akhil Kaushik114 visualizações
Subprogram por baran19901990
SubprogramSubprogram
Subprogram
baran199019901.6K visualizações
Unit 3 sp assembler por Deepmala Sharma
Unit 3 sp assemblerUnit 3 sp assembler
Unit 3 sp assembler
Deepmala Sharma30.5K visualizações
C programming por KarthicaMarasamy
C programmingC programming
C programming
KarthicaMarasamy88 visualizações
Programming the basic computer por Kamal Acharya
Programming the basic computerProgramming the basic computer
Programming the basic computer
Kamal Acharya1.3K visualizações
System Programing Unit 1 por Manoj Patil
System Programing Unit 1System Programing Unit 1
System Programing Unit 1
Manoj Patil57.2K visualizações

Similar a C- language Lecture 4

CPP11 - Function Design por
CPP11 - Function DesignCPP11 - Function Design
CPP11 - Function DesignMichael Heron
298 visualizações25 slides
Chapter One Function.pptx por
Chapter One Function.pptxChapter One Function.pptx
Chapter One Function.pptxmiki304759
13 visualizações60 slides
C programming for Computing Techniques por
C programming for Computing TechniquesC programming for Computing Techniques
C programming for Computing TechniquesAppili Vamsi Krishna
906 visualizações260 slides
Algorithmic problem sloving por
Algorithmic problem slovingAlgorithmic problem sloving
Algorithmic problem slovingMani Kandan
272 visualizações79 slides
C programming por
C programmingC programming
C programmingJigarthacker
1.7K visualizações24 slides
Algorithms and flow charts por
Algorithms and flow chartsAlgorithms and flow charts
Algorithms and flow chartsChinnu Edwin
178 visualizações19 slides

Similar a C- language Lecture 4(20)

CPP11 - Function Design por Michael Heron
CPP11 - Function DesignCPP11 - Function Design
CPP11 - Function Design
Michael Heron298 visualizações
Chapter One Function.pptx por miki304759
Chapter One Function.pptxChapter One Function.pptx
Chapter One Function.pptx
miki30475913 visualizações
C programming for Computing Techniques por Appili Vamsi Krishna
C programming for Computing TechniquesC programming for Computing Techniques
C programming for Computing Techniques
Appili Vamsi Krishna906 visualizações
Algorithmic problem sloving por Mani Kandan
Algorithmic problem slovingAlgorithmic problem sloving
Algorithmic problem sloving
Mani Kandan272 visualizações
C programming por Jigarthacker
C programmingC programming
C programming
Jigarthacker1.7K visualizações
Algorithms and flow charts por Chinnu Edwin
Algorithms and flow chartsAlgorithms and flow charts
Algorithms and flow charts
Chinnu Edwin178 visualizações
Coding por Anand Mutyala
CodingCoding
Coding
Anand Mutyala257 visualizações
5. Functions in C.pdf por santosh147365
5. Functions in C.pdf5. Functions in C.pdf
5. Functions in C.pdf
santosh14736524 visualizações
DS functions-1.pptx por HarikishnaKNHk
DS functions-1.pptxDS functions-1.pptx
DS functions-1.pptx
HarikishnaKNHk3 visualizações
An intuitive guide to combining free monad and free applicative por Cameron Joannidis
An intuitive guide to combining free monad and free applicativeAn intuitive guide to combining free monad and free applicative
An intuitive guide to combining free monad and free applicative
Cameron Joannidis398 visualizações
COMPUTING AND PROGRAMMING FUNDAMENTAL.pptx por SherinRappai1
COMPUTING AND PROGRAMMING FUNDAMENTAL.pptxCOMPUTING AND PROGRAMMING FUNDAMENTAL.pptx
COMPUTING AND PROGRAMMING FUNDAMENTAL.pptx
SherinRappai12 visualizações
COMPUTING AND PROGRAMMING FUNDAMENTAL.pptx por SherinRappai
COMPUTING AND PROGRAMMING FUNDAMENTAL.pptxCOMPUTING AND PROGRAMMING FUNDAMENTAL.pptx
COMPUTING AND PROGRAMMING FUNDAMENTAL.pptx
SherinRappai2 visualizações
Coding por Vishal Singh
CodingCoding
Coding
Vishal Singh13.3K visualizações
Chapter Introduction to Modular Programming.ppt por AmanuelZewdie4
Chapter Introduction to Modular Programming.pptChapter Introduction to Modular Programming.ppt
Chapter Introduction to Modular Programming.ppt
AmanuelZewdie4329 visualizações
Keeping code clean por Brett Child
Keeping code cleanKeeping code clean
Keeping code clean
Brett Child1.2K visualizações
Functions and procedures por underwan
Functions and proceduresFunctions and procedures
Functions and procedures
underwan732 visualizações
Embedded _c_ por Moorthy Peesapati
Embedded  _c_Embedded  _c_
Embedded _c_
Moorthy Peesapati3.1K visualizações
INLINE FUNCTION IN C++ por Vraj Patel
INLINE FUNCTION IN C++INLINE FUNCTION IN C++
INLINE FUNCTION IN C++
Vraj Patel6K visualizações
Programming using C++ - slides.pptx por HeadoftheDepartment
Programming using C++ - slides.pptxProgramming using C++ - slides.pptx
Programming using C++ - slides.pptx
HeadoftheDepartment15 visualizações

Mais de Hatem Abd El-Salam

Java- language Lecture 7 por
Java- language Lecture 7Java- language Lecture 7
Java- language Lecture 7Hatem Abd El-Salam
166 visualizações24 slides
Java- language Lecture 6 por
Java- language Lecture 6Java- language Lecture 6
Java- language Lecture 6Hatem Abd El-Salam
76 visualizações45 slides
Java- language Lecture 5 por
Java- language Lecture 5Java- language Lecture 5
Java- language Lecture 5Hatem Abd El-Salam
76 visualizações49 slides
Java- language Lecture 4 por
Java- language Lecture 4Java- language Lecture 4
Java- language Lecture 4Hatem Abd El-Salam
182 visualizações17 slides
Java- language Lecture 3 por
Java- language Lecture 3Java- language Lecture 3
Java- language Lecture 3Hatem Abd El-Salam
63 visualizações30 slides
Java- Language Lecture 2 por
Java- Language Lecture 2Java- Language Lecture 2
Java- Language Lecture 2Hatem Abd El-Salam
151 visualizações21 slides

Mais de Hatem Abd El-Salam(12)

Java- language Lecture 7 por Hatem Abd El-Salam
Java- language Lecture 7Java- language Lecture 7
Java- language Lecture 7
Hatem Abd El-Salam166 visualizações
Java- language Lecture 6 por Hatem Abd El-Salam
Java- language Lecture 6Java- language Lecture 6
Java- language Lecture 6
Hatem Abd El-Salam76 visualizações
Java- language Lecture 5 por Hatem Abd El-Salam
Java- language Lecture 5Java- language Lecture 5
Java- language Lecture 5
Hatem Abd El-Salam76 visualizações
Java- language Lecture 4 por Hatem Abd El-Salam
Java- language Lecture 4Java- language Lecture 4
Java- language Lecture 4
Hatem Abd El-Salam182 visualizações
Java- language Lecture 3 por Hatem Abd El-Salam
Java- language Lecture 3Java- language Lecture 3
Java- language Lecture 3
Hatem Abd El-Salam63 visualizações
Java- Language Lecture 2 por Hatem Abd El-Salam
Java- Language Lecture 2Java- Language Lecture 2
Java- Language Lecture 2
Hatem Abd El-Salam151 visualizações
Java- language Lecture 1 por Hatem Abd El-Salam
Java- language Lecture 1Java- language Lecture 1
Java- language Lecture 1
Hatem Abd El-Salam168 visualizações
introduction to embedded systems part 2 por Hatem Abd El-Salam
introduction to embedded systems part 2introduction to embedded systems part 2
introduction to embedded systems part 2
Hatem Abd El-Salam226 visualizações
introduction to embedded systems part 1 por Hatem Abd El-Salam
introduction to embedded systems part 1introduction to embedded systems part 1
introduction to embedded systems part 1
Hatem Abd El-Salam244 visualizações
C- language Lecture 3 por Hatem Abd El-Salam
C- language Lecture 3C- language Lecture 3
C- language Lecture 3
Hatem Abd El-Salam775 visualizações
C- Language Lecture 2 por Hatem Abd El-Salam
C- Language Lecture 2C- Language Lecture 2
C- Language Lecture 2
Hatem Abd El-Salam375 visualizações
C-language Lecture 1 por Hatem Abd El-Salam
C-language Lecture 1C-language Lecture 1
C-language Lecture 1
Hatem Abd El-Salam554 visualizações

Último

The basics - information, data, technology and systems.pdf por
The basics - information, data, technology and systems.pdfThe basics - information, data, technology and systems.pdf
The basics - information, data, technology and systems.pdfJonathanCovena1
146 visualizações1 slide
Thanksgiving!.pdf por
Thanksgiving!.pdfThanksgiving!.pdf
Thanksgiving!.pdfEnglishCEIPdeSigeiro
264 visualizações17 slides
Jibachha publishing Textbook.docx por
Jibachha publishing Textbook.docxJibachha publishing Textbook.docx
Jibachha publishing Textbook.docxDrJibachhaSahVetphys
51 visualizações14 slides
Psychology KS5 por
Psychology KS5Psychology KS5
Psychology KS5WestHatch
119 visualizações5 slides
Drama KS5 Breakdown por
Drama KS5 BreakdownDrama KS5 Breakdown
Drama KS5 BreakdownWestHatch
98 visualizações2 slides
S1_SD_Resources Walkthrough.pptx por
S1_SD_Resources Walkthrough.pptxS1_SD_Resources Walkthrough.pptx
S1_SD_Resources Walkthrough.pptxLAZAROAREVALO1
64 visualizações57 slides

Último(20)

The basics - information, data, technology and systems.pdf por JonathanCovena1
The basics - information, data, technology and systems.pdfThe basics - information, data, technology and systems.pdf
The basics - information, data, technology and systems.pdf
JonathanCovena1146 visualizações
Jibachha publishing Textbook.docx por DrJibachhaSahVetphys
Jibachha publishing Textbook.docxJibachha publishing Textbook.docx
Jibachha publishing Textbook.docx
DrJibachhaSahVetphys51 visualizações
Psychology KS5 por WestHatch
Psychology KS5Psychology KS5
Psychology KS5
WestHatch119 visualizações
Drama KS5 Breakdown por WestHatch
Drama KS5 BreakdownDrama KS5 Breakdown
Drama KS5 Breakdown
WestHatch98 visualizações
S1_SD_Resources Walkthrough.pptx por LAZAROAREVALO1
S1_SD_Resources Walkthrough.pptxS1_SD_Resources Walkthrough.pptx
S1_SD_Resources Walkthrough.pptx
LAZAROAREVALO164 visualizações
11.28.23 Social Capital and Social Exclusion.pptx por mary850239
11.28.23 Social Capital and Social Exclusion.pptx11.28.23 Social Capital and Social Exclusion.pptx
11.28.23 Social Capital and Social Exclusion.pptx
mary850239312 visualizações
Google solution challenge..pptx por ChitreshGyanani1
Google solution challenge..pptxGoogle solution challenge..pptx
Google solution challenge..pptx
ChitreshGyanani1148 visualizações
Education and Diversity.pptx por DrHafizKosar
Education and Diversity.pptxEducation and Diversity.pptx
Education and Diversity.pptx
DrHafizKosar193 visualizações
CUNY IT Picciano.pptx por apicciano
CUNY IT Picciano.pptxCUNY IT Picciano.pptx
CUNY IT Picciano.pptx
apicciano54 visualizações
Women from Hackney’s History: Stoke Newington by Sue Doe por History of Stoke Newington
Women from Hackney’s History: Stoke Newington by Sue DoeWomen from Hackney’s History: Stoke Newington by Sue Doe
Women from Hackney’s History: Stoke Newington by Sue Doe
History of Stoke Newington163 visualizações
The Accursed House by Émile Gaboriau por DivyaSheta
The Accursed House  by Émile GaboriauThe Accursed House  by Émile Gaboriau
The Accursed House by Émile Gaboriau
DivyaSheta223 visualizações
Pharmaceutical Inorganic chemistry UNIT-V Radiopharmaceutical.pptx por Ms. Pooja Bhandare
Pharmaceutical Inorganic chemistry UNIT-V Radiopharmaceutical.pptxPharmaceutical Inorganic chemistry UNIT-V Radiopharmaceutical.pptx
Pharmaceutical Inorganic chemistry UNIT-V Radiopharmaceutical.pptx
Ms. Pooja Bhandare113 visualizações
REPRESENTATION - GAUNTLET.pptx por iammrhaywood
REPRESENTATION - GAUNTLET.pptxREPRESENTATION - GAUNTLET.pptx
REPRESENTATION - GAUNTLET.pptx
iammrhaywood138 visualizações
AUDIENCE - BANDURA.pptx por iammrhaywood
AUDIENCE - BANDURA.pptxAUDIENCE - BANDURA.pptx
AUDIENCE - BANDURA.pptx
iammrhaywood117 visualizações
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB... por Nguyen Thanh Tu Collection
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
Nguyen Thanh Tu Collection88 visualizações
Gopal Chakraborty Memorial Quiz 2.0 Prelims.pptx por Debapriya Chakraborty
Gopal Chakraborty Memorial Quiz 2.0 Prelims.pptxGopal Chakraborty Memorial Quiz 2.0 Prelims.pptx
Gopal Chakraborty Memorial Quiz 2.0 Prelims.pptx
Debapriya Chakraborty695 visualizações
Gross Anatomy of the Liver por obaje godwin sunday
Gross Anatomy of the LiverGross Anatomy of the Liver
Gross Anatomy of the Liver
obaje godwin sunday61 visualizações

C- language Lecture 4

  • 1. Lecture 4 C Language ENG : HATEM ABD EL-SALAM
  • 2. • Goto • Functions • Recursion Agenda
  • 3. Goto • The goto statement is used to alter the normal sequence of a C program. • The label is an identifier. When goto statement is encountered, control of the program jumps to label: and starts executing the code.
  • 5. Goto (Cont.) Reasons to avoid goto statement • The use of goto statement may lead to code that is buggy and hard to follow. For example • goto statement allows you to do bad stuff such as jump out of scope • But, goto statement can be useful sometimes. For example: to break from nested loops.
  • 8. Functions A function is a block of code that performs a specific task. Suppose, a program related to graphics needs to create a circle and color it depending upon the radius and color from the user. You can create two functions to solve this problem: • create a circle function • color function Dividing complex problem into small components makes program easy to understand and use.
  • 10. Functions (Cont.) • How user-defined function works
  • 11. Functions (Cont.) • How to pass argument to function
  • 12. Functions (Cont.) • Return statement of function
  • 14. Functions (Cont.) • Keys of Functions:  It can return one or no values  It may accept as many parameters it needs or no parameter at all  After the Function has finished execution. It goes back to the Function that called it  Function names should be verbs  Function name is an identifier and should be unique.
  • 15. Functions (Cont.) Advantages of function • The program will be easier to understand, maintain and debug. • Reusable codes that can be used in other programs • A large program can be divided into smaller modules. Hence, a large project can be divided among many programmers.
  • 18. Recursion Advantages of recursion • Recursion makes program elegant and cleaner. All algorithms can be defined recursively which makes it easier to visualize and prove. Reusable codes that can be used in other programs Disadvantages of recursion • If the speed of the program is vital then, you should avoid using recursion. Recursions use more memory and are generally slow