SlideShare a Scribd company logo
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

More Related Content

PDF
C- language Lecture 8
PDF
C- language Lecture 6
PDF
C- language Lecture 5
PDF
C- language Lecture 7
PDF
Embedded C - Optimization techniques
PPTX
Decision Making & Loops
PDF
08 subprograms
PPTX
Compiler construction tools
C- language Lecture 8
C- language Lecture 6
C- language Lecture 5
C- language Lecture 7
Embedded C - Optimization techniques
Decision Making & Loops
08 subprograms
Compiler construction tools

What's hot (20)

PPTX
Code Optimization
PPTX
Lecture 15 run timeenvironment_2
PPTX
Algorithms & Complexity Calculation
PDF
Hm system programming class 1
PDF
Learning New Semi-Supervised Deep Auto-encoder Features for Statistical Machi...
PPTX
System Programming Unit III
PPTX
Workshop Assembler
PDF
Compiler Design- Machine Independent Optimizations
PPT
what is compiler and five phases of compiler
PPTX
C basics
DOCX
Compiler Design Material
PPTX
Intro to Data Structure & Algorithms
PDF
PPT
Compiler Design Basics
PDF
Subprogram
PPTX
Unit 3 sp assembler
PPTX
C programming
PPTX
Programming the basic computer
PPTX
System Programing Unit 1
Code Optimization
Lecture 15 run timeenvironment_2
Algorithms & Complexity Calculation
Hm system programming class 1
Learning New Semi-Supervised Deep Auto-encoder Features for Statistical Machi...
System Programming Unit III
Workshop Assembler
Compiler Design- Machine Independent Optimizations
what is compiler and five phases of compiler
C basics
Compiler Design Material
Intro to Data Structure & Algorithms
Compiler Design Basics
Subprogram
Unit 3 sp assembler
C programming
Programming the basic computer
System Programing Unit 1
Ad

Similar to C- language Lecture 4 (20)

PPTX
CPP11 - Function Design
PPTX
Chapter One Function.pptx
PPT
C programming for Computing Techniques
PDF
Algorithmic problem sloving
PPTX
C programming
PPTX
Algorithms and flow charts
PPTX
Functions and structure in programming c
PPT
PPTX
1.0 Introduction to C programming for all first year courses.pptx
PDF
5. Functions in C.pdf
PPTX
DS functions-1.pptx
PDF
An intuitive guide to combining free monad and free applicative
PPTX
COMPUTING AND PROGRAMMING FUNDAMENTAL.pptx
PPTX
COMPUTING AND PROGRAMMING FUNDAMENTAL.pptx
PPT
Coding
PPTX
UNIT - 1jhjhjbkjhkjhkjhkjhkjhhkkhhh.pptx
PPTX
Software engineering topics,coding phase in sdlc
PPTX
MODULE 2.pptx Python data handling types function
PPT
chapterintroductiontomodularprogramming-230112092330-e3eb5a74 (1).ppt
PPT
Chapter Introduction to Modular Programming.ppt
CPP11 - Function Design
Chapter One Function.pptx
C programming for Computing Techniques
Algorithmic problem sloving
C programming
Algorithms and flow charts
Functions and structure in programming c
1.0 Introduction to C programming for all first year courses.pptx
5. Functions in C.pdf
DS functions-1.pptx
An intuitive guide to combining free monad and free applicative
COMPUTING AND PROGRAMMING FUNDAMENTAL.pptx
COMPUTING AND PROGRAMMING FUNDAMENTAL.pptx
Coding
UNIT - 1jhjhjbkjhkjhkjhkjhkjhhkkhhh.pptx
Software engineering topics,coding phase in sdlc
MODULE 2.pptx Python data handling types function
chapterintroductiontomodularprogramming-230112092330-e3eb5a74 (1).ppt
Chapter Introduction to Modular Programming.ppt
Ad

More from Hatem Abd El-Salam (12)

PDF
Java- language Lecture 7
PDF
Java- language Lecture 6
PDF
Java- language Lecture 5
PDF
Java- language Lecture 4
PDF
Java- language Lecture 3
PDF
Java- Language Lecture 2
PDF
Java- language Lecture 1
PDF
introduction to embedded systems part 2
PDF
introduction to embedded systems part 1
PDF
C- language Lecture 3
PDF
C- Language Lecture 2
PDF
C-language Lecture 1
Java- language Lecture 7
Java- language Lecture 6
Java- language Lecture 5
Java- language Lecture 4
Java- language Lecture 3
Java- Language Lecture 2
Java- language Lecture 1
introduction to embedded systems part 2
introduction to embedded systems part 1
C- language Lecture 3
C- Language Lecture 2
C-language Lecture 1

Recently uploaded (20)

PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
GDM (1) (1).pptx small presentation for students
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPTX
Cell Types and Its function , kingdom of life
PPTX
Cell Structure & Organelles in detailed.
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
Institutional Correction lecture only . . .
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Pre independence Education in Inndia.pdf
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
GDM (1) (1).pptx small presentation for students
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Abdominal Access Techniques with Prof. Dr. R K Mishra
Supply Chain Operations Speaking Notes -ICLT Program
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Cell Types and Its function , kingdom of life
Cell Structure & Organelles in detailed.
TR - Agricultural Crops Production NC III.pdf
Final Presentation General Medicine 03-08-2024.pptx
Renaissance Architecture: A Journey from Faith to Humanism
Module 4: Burden of Disease Tutorial Slides S2 2025
Institutional Correction lecture only . . .
2.FourierTransform-ShortQuestionswithAnswers.pdf
O5-L3 Freight Transport Ops (International) V1.pdf
Pharmacology of Heart Failure /Pharmacotherapy of CHF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
O7-L3 Supply Chain Operations - ICLT Program
Pre independence Education in Inndia.pdf

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