Class 10 Computer Science Chapter 7 SEBA : Functions in C – Important Question Answers

Class 10 Computer Science Chapter 7 SEBA : Functions in C – Important Question Answers

Class 10 Computer Science Chapter 7 Seba, Functions in C class 10 seba computer science, Class 10 Computer Science Chapter 7 seba question answers, chapter 7 computer science class 10 seba, computer science class 10 chapter 7 seba

(Class 10 Computer Science Chapter 7 SEBA : Functions in C, Functions in C class 10 seba computer science, Class 10 Computer Science Chapter 7 seba question answers, chapter 7 computer science class 10 seba, computer science class 10 chapter 7 seba)

SEBA Class 10 Computer Science Chapter 7 – Functions in C: This page provides exercise questions and answers, solutions and explanations for SEBA Class 10 Computer Science Chapter 7. The answers are written in simple and easy-to-understand language to help students understand the concepts of functions in C and prepare effectively for their examinations.

Class 10 Computer Science Chapter 7 SEBA : Functions in C, Functions in C class 10 seba computer science, Class 10 Computer Science Chapter 7 seba question answers, chapter 7 computer science class 10 seba, computer science class 10 chapter 7 seba

Class 10 Computer Science Chapter 7 Seba, Functions in C class 10 seba computer science, Class 10 Computer Science Chapter 7 seba question answers, chapter 7 computer science class 10 seba, computer science class 10 chapter 7 seba

Class 10 Computer Science Chapter 7: Functions in C – Exercise Questions Answers

1. What is a global variable in C? Why do we need such a variable?

Ans: A global variable in C is a variable that is declared outside all functions, usually before the main() function. It can be accessed directly by any function in the program.

We need a global variable when the same data needs to be used by more than one function.

2. Write the syntax of a function declaration. The name of the function is calculateAge(). The function accepts the current year and birth year of a person. The function returns the age of the person.

Ans:-
The function declaration is given below:
int calculateAge ( int currentYear , int birthYear ) ;

3. Write the code segment for the function definition of the above function calculateAge().

Ans:-
The function definition is given below:
int calculateAge ( int currentYear , int birthYear )
{
int age = currentYear – birthYear ;
return age ;
}

4. What are different types of functions in C ? Differentiate among them.

Ans:– The different types of functions in C are Library Functions and User-defined Functions.

1. Library Functions: These functions are already available in the C library. We can use them directly in our programs. Examples are printf(), scanf(), strlen() and sqrt(), etc.

2. User-defined Functions: These are functions created by the programmer to perform a particular task. Examples: sum() and calculate_interest(), etc.

Difference: Library functions are already available in C, while user-defined functions are created by the programmer.

5. Differentiate between caller and callee functions. write a small C progarm and identify the caller and callee function in it.

Ans:–
Caller Function: The function that calls another function is called the caller function.
Callee Function: The function that is called by another function is called the callee function.

A Simple C program is given below:
#include <stdio.h>
int sum(int a, int b)
{
   return a + b;
}
int main()
{
   int result = sum(10, 20);
   printf(“%d”, result);
   return 0;
}

Here, main() is the caller function because it calls sum(). On the other hand, sum() is the callee function because it is called by main().

6. When do we call a function user-defined? Is printf() a user-defined function? Justify.

Ans: A function is called user-defined when it is created and defined by the programmer according to the requirements of the program.

No, printf() is not a user-defined function. It is a library function because its definition is already provided in the C library. We can use it directly in our program.

7. Can we have two functions with the same name but with different numbers of parameters in a single C program? Write a simple C program to justify your answer.

Ans: No, we cannot have two functions with the same name but different numbers of parameters in a C program. C does not support function overloading.

A simple C program is given below:

#include <stdio.h>
int sum(int a, int b)
{
return a + b;
}
int sum(int a, int b, int c)
{
return a + b + c;
}

The above program will give an error because both functions have the same name sum().

8. What are different components of a function? Show with a complete C program.

Answer:

Ans: There are three main components of a function in C:

  1. Function Declaration: It tells the compiler about the function name, parameters and return type.
  2. Function Call: It is a statement used to call a function. The function starts executing when it is called.
  3. Function Definition: It contains the actual statements that are executed when the function is called.

A C program is given below:

Class 10 Computer Science Chapter 7 SEBA : Functions in C, Functions in C class 10 seba computer science, Class 10 Computer Science Chapter 7 seba question answers, chapter 7 computer science class 10 seba, computer science class 10 chapter 7 seba

9. Define recursive function. Can we use a recursive function to solve all kinds of problems?

Ans: A recursive function is a function that calls itself. This process is called recursion.

No, we cannot use a recursive function to solve all kinds of problems. It is useful only for problems where a function can solve a smaller part of the same problem.

10. Consider the below code and list all the syntax errors.

Class 10 Computer Science Chapter 7 SEBA : Functions in C, Functions in C class 10 seba computer science, Class 10 Computer Science Chapter 7 seba question answers, chapter 7 computer science class 10 seba, computer science class 10 chapter 7 seba

10. Ans:- The syntax errors are given below:

Missing argument in fun( ) function.
The fun( ) function needs to be called with arguments.

For example,
int x = fun(number);

11. Consider the code segment below and find out the output if the user enters 5 from the keyboard when asked for.

Class 10 Computer Science Chapter 7 SEBA : Functions in C, Functions in C class 10 seba computer science, Class 10 Computer Science Chapter 7 seba question answers, chapter 7 computer science class 10 seba, computer science class 10 chapter 7 seba

Ans: The output is 0.
Because, When the user enters 5, fun(5) checks whether the number is even or not. Since 5 % 2 is not equal to 0, and the function returns 0.

12. Write a C program and define a function square() that accepts a number as the parameter and returns the square of that number as output.

Ans:-
#include<stdio.h>
float square(float n)
{
                float result=n*n;
                return result;
}
int main()
{
                float n, result;
                printf(“\n Enter a number:”);
                scanf(“%f”, &n);
                result=square(n);
                printf(“\n The square of the number %f”, result);
                return 0;
}

13. Write a C program and define a function search () that searches an element in an array and returns the index of the element.

Ans:-
#include <stdio.h>
int search(int a[ ], int b, int c)
{
    for (int i = 0; i < b; i++)
        {
        if (a[i] == c)
              {
            printf(“Number found at index %d”, i );
            return 1;
              }
        }
    printf(“Number not found”);
}

int main()
{
    int a[20], b, c;
    printf(“Enter total number of elements: “);
    scanf(“%d”, &b);
    for (int i = 0; i < b; i++)
        {
        printf(“Enter element %d: “, i + 1);
        scanf(“%d”, &a[i]);
        }
    printf(“Enter the number you want to search: “);
    scanf(“%d”, &c);
    search(a, b, c);
    return 0;
}

14. Write a C program and define a recursive function to find the summation of first N natural numbers.

#include <stdio.h>
int sum(int n)
{
    if(n == 0)
        return 0;
    return n + sum(n – 1);
}
 
int main()
{
    int n;
    printf(“Enter a number: “);
    scanf(“%d”, &n);
    printf(“Summation is %d”, sum(n));
    return 0;
}

15. Write a C program and define a function add() that accepts three integers. These integers indicate indices of an integer array. The function returns the summation of the elements stored in those indices.

788009

For example, if we call the function add( 0, 2, 5), the function will return 24. The output is formed by 7 + 8 + 9 because elements at indices 0, 2 and 5 are 7, 8 and 9 respectively.

15. Ans:-
#include <stdio.h>
int n[ ] = {7, 8, 8, 0, 0, 9};
int add(int a, int b, int c)
{
                int result = n[a] + n[b] + n[c] ;
                return result ;
}
int main( )
{
                printf(“Summation is %d”, add(0, 2, 5) ) ;
                return 0 ;
}

Related Class 10 Computer Science Chapters of SEBA :

→ Chapter 1 SEBA : Introduction to Computer Network
→ Chapter 4 SEBA : Introduction to Loops
→ Chapter 5 SEBA : Nested loops in C
→ Chapter 6 SEBA : Arrays in C

Class 10 Computer Science Chapter 7 Seba, Functions in C class 10 seba computer science, Class 10 Computer Science Chapter 7 seba question answers, chapter 7 computer science class 10 seba, computer science class 10 chapter 7 seba

Class 10 Computer Science Chapter 7 SEBA : Functions in C, Functions in C class 10 seba computer science, Class 10 Computer Science Chapter 7 seba question answers, chapter 7 computer science class 10 seba, computer science class 10 chapter 7 seba

Important Points to Remember About Functions in C

  • A function is a block of statements that performs a specific task.
  • Functions help divide a large program into smaller and manageable parts.
  • A function can be called whenever it is required in a program.
  • The function from which program execution begins is the main() function.
  • A function can accept values through parameters and may return a value to the calling function.
  • The function declaration (prototype) tells the compiler about the function’s name, return type and parameters.
  • The function definition contains the actual statements that perform the task.
  • A function call is used to execute a function.
  • Functions can be classified as library functions and user-defined functions.
  • Examples of library functions include printf(), scanf(), strlen() and sqrt().
  • A recursive function is a function that calls itself.
  • Every recursive function should have a base condition to stop further calls.
  • The return statement is used to return a value from a function.
  • Functions improve code reusability, readability and maintainability.
  • In C, arguments can be passed to functions by value; C does not have true pass-by-reference parameters.
  • The return type specifies the type of value returned by a function. If a function does not return a value, void can be used.
  • If no return type is specified, it defaults to int (bad practice; always specify).
  • int f(void) means the function takes no arguments.
  • Arrays passed to functions are actually passed by address, so the function can modify the original array.
  • Pass-by-reference can be simulated using pointers, since C has no true reference parameters.
  • A function can return only one value directly; use pointers or structs to return more.
  • Nested function definitions are not allowed in standard C.
  • Recursive functions use stack memory; deep recursion can cause a stack overflow.
  • Functions reduce code duplication and make programs easier to debug and maintain.

Class 10 Computer Science Chapter 7 Seba, Functions in C class 10 seba computer science, Class 10 Computer Science Chapter 7 seba question answers, chapter 7 computer science class 10 seba, computer science class 10 chapter 7 seba
Class 10 Computer Science Chapter 7 SEBA : Functions in C, Functions in C class 10 seba computer science, Class 10 Computer Science Chapter 7 seba question answers, chapter 7 computer science class 10 seba, computer science class 10 chapter 7 seba

In the SEBA Class 10 Computer Science Chapter 7 syllabus, Functions in C introduces students to modular programming, a cornerstone of efficient software design. As programs grow larger, placing all instructions inside a single main() block makes code difficult to trace and maintain. Understanding Functions in C Class 10 SEBA Computer Science helps students learn how to break complex tasks into smaller, reusable, and independent sub-programs.

This complete guide for Chapter 7 Computer Science Class 10 SEBA covers essential concepts, core advantages, function categories, and high-yield Class 10 Computer Science Chapter 7 SEBA question answers to help students score top marks in board exams.

Key Concepts: Functions in C Class 10 SEBA Computer Science

A function in C is a self-contained block of statements designed to perform a specific task. By using functions, programmers eliminate code duplication, improve program readability, and simplify debugging.

Types of Functions

In Computer Science Class 10 Chapter 7 SEBA, functions are divided into two primary categories:

  1. Library Functions (Built-in Functions): Predefined functions stored in standard header files (e.g., printf() and scanf() in , `sqrt()` and `pow()` in ).
  2. User-Defined Functions: Custom functions created by the programmer to meet specific application requirements.

Three Main Elements of User-Defined Functions

  • Function Declaration (Prototype): Specifies the function name, return type, and argument list to the compiler before execution.
  • Function Definition: Contains the actual set of instructions that execute when the function is called.
  • Function Call: Statement that invokes the function from main() or another function.

Class 10 Computer Science Chapter 7 SEBA Question Answers

Below are important, board exam-oriented questions and answers written in clear, simple English for fast revision.

Section A: Very Short Answer Questions (1 Mark Each)

Q1. What is a function in C programming?

Ans: A function is a named block of reusable code designed to perform a specific, well-defined task.

Q2. Which keyword is used when a function does not return any value?

Ans: The void keyword is used as the return type when a function returns no value.

Q3. What is the purpose of a function prototype in Chapter 7 Computer Science Class 10 SEBA?

Ans: A function prototype informs the compiler about the function’s name, return type, and parameters before it is used in the program.

Q4. Give two examples of standard library functions in C.

Ans: printf() and scanf().

Section B: Short Answer Questions (2–3 Marks Each)

Q5. State two main advantages of using functions in C.

Ans:

  • Code Reusability: Once written, a function can be executed multiple times without repeating code.
  • Easier Debugging: Isolating tasks into separate functions makes tracking and fixing errors simple and fast.

Q6. Differentiate between Library Functions and User-Defined Functions.

Ans:

FeatureLibrary FunctionsUser-Defined Functions
DefinitionPredefined in standard C header filesCreated by the programmer as needed
ModificationCannot be modified by the userFully customizable by the user
Examplessqrt(), strlen(), printf()calculateSum(), checkEven()

Q7. Explain the difference between Call by Value and Call by Reference.

Ans:

  • Call by Value: Passes a copy of the actual argument to the function. Changes made inside the function do not affect the original variable.
  • Call by Reference: Passes the memory address of the variable, allowing the function to modify the original variable directly.

Summary for Computer Science Class 10 Chapter 7 SEBA

Mastering Functions in C in SEBA Class 10 Computer Science Chapter 7 establishes a strong foundation for advanced coding, modular problem solving, and upcoming programming units. Reviewing these Class 10 Computer Science Chapter 7 SEBA question answers ensures quick, reliable preparation for both school evaluations and final SEBA board examinations.

error: Content is protected !!