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.
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