Class 10 Computer Science Unit 5 – Functions focuses on breaking programs into smaller, manageable blocks called functions. This helps students write organized, reusable, and efficient code.
In this unit, students learn about:
-
Definition and purpose of functions
-
Types of functions (built-in and user-defined)
-
Function declaration, definition, and calling
-
Passing arguments to functions
-
Return values from functions
These notes include solved MCQs, short questions, long questions, and examples for easy understanding.
Important MCQs – Unit 5 Functions
1. The functions which are available in C Standard Library are called:
a) User-defined
b) Built-in ✅
c) Recursive
d) Repetitive
2. printf() function is used to:
a) Take input from the user
b) Display output on the screen ✅
c) Perform calculations
d) Terminate a program
3. scanf() function is used to:
a) Display output
b) Take input from the user ✅
c) Print values
d) Store data permanently
4. Functions defined by the programmer are called:
a) Built-in functions
b) User-defined functions ✅
c) Main functions
d) Inline functions
Short Questions – Unit 5 Functions
1. What is a function in C language?
Answer:
A function is a block of statements that performs a specific task in a program. Functions help in breaking programs into smaller, manageable parts, making the code organized, reusable, and easier to maintain.
2. What are built-in functions? Give two examples.
Answer:
Built-in functions are pre-defined functions available in the C Standard Library. These functions perform common tasks like input/output, string handling, and mathematical operations, so programmers do not need to write them from scratch.
Examples:
-
printf()→ Displays output on the screen -
scanf()→ Takes input from the user
3. What are user-defined functions?
Answer:
User-defined functions are functions created by the programmer to perform specific tasks in a program. They help in breaking large programs into smaller, manageable parts, making the code organized, reusable, and easier to maintain.
Long Questions – Unit 5 Functions
Q1: What is a function in C language? Describe its types with examples.
Introduction:
In C programming, functions play a vital role in organizing and managing code efficiently. Instead of writing the same code repeatedly, a program is divided into smaller modules called functions. This approach enhances code readability, modularity, and reusability. Every C program must have a main() function, but programmers can also create their own functions to perform specific tasks.
Definition:
A function is a block of statements designed to perform a specific task. Once defined, a function can be called anywhere in the program to execute that task.
Types of Functions in C:
1. Built-in Functions:
-
Pre-defined functions available in the C Standard Library.
-
Used for common tasks like input/output, mathematical operations, and string handling.
-
Examples:
printf(),scanf(),sqrt(),strlen()
Example:
2. User-Defined Functions:
-
Created by the programmer to perform custom tasks.
-
Help in performing user-specific operations like calculations or data processing.
-
Example: A function to add two numbers or calculate area.
Example:
printf(“Welcome to C programming!”);
}
int main() {
greet(); // Function call
return 0;
}
Output:
Closing Statement:
Functions improve program structure, make code modular and reusable, and simplify debugging. Understanding the types of functions helps students write efficient and organized programs in C.
Download PDF
Download the complete chapter notes in PDF for easy learning and quick exam revision.
English Medium
Includes all examples, solved questions, and detailed explanations.
Urdu Medium
Available in Urdu for better understanding and exam preparation.