Class Matric Part 2 NotesComputer class 10th

10th class computer science chapter 5 Functions

10th class computer science chapter 5 Functions on Newsongoogle.com by Bilal Article

Shorts and Simple Question & Answers

Q.1: What is problem solving?
Ans.
The process of solving difficult and complex problem is called problem solving. To solve a problem, one has to adopt a systematic strategy.


Q.2: Define divide and conquer?
Ans.
complex problem is divided into small problems. The smaller problems can be solved separately to find the solution of the problem and then integrating all the solutions. In this way, it becomes easier for us to focus on a single smaller problem at a time, instead of thinking about the whole problem all the time. This problem solving approach is called divide and conquer.


Q.3: What do you know about function of C language?
Ans.
A function is a block of statements which performs a particular task. Each program has a main function which performs the tasks programmed by the user. Similarly, we can write other functions and use them multiple times.


Q.4: Write down the name of types of Functions.
Ans.
There are basically two types of functions:
Built-in Functions
User Defined Functions


Q.5: Define built in functions?
Ans.
The functions which are already defined in C programming language are called built-in functions. These functions are also called library functions. These functions are available as a
part of language.


Q.6: Define user defined functions?
Ans.
The functions which are defined by a programmer to perform specific tasks are called user- defined functions. These functions are written according to the exact need of the user.


Q.7: Write advantages of Functions.
Ans.
Following are the advantages of Functions:
Reusability
Separation of task
Readability
Handling the Complexity of the problem.


Q.8: Define reusability?
Ans.
Functions provide reusability of code. It means that whenever we need to use the functionality provided by the function, we just call the function. We do not need to write the same set of statements again and again.


Q.9: Define separation of task?
Ans.
Functions allow us to separate the code of one task from the code of other tasks. If we have a problem in one function, then we do not need to check the whole program for removing the problem. We just need to focus at one single function.


Q.10: Define readability?
Ans.
Dividing the program into multiple functions, improves the readability of the program.


Q.11: Define the term handling the complexity of the problem?
Ans.
If we write the whole program as a single procedure, management of the program becomes difficult. Functions divide the program into smaller units, and thus reduce the complexity of the problem.


Q.12: What is the use of functions signature?
Ans.
Function signature is used to define the inputs and output of a function.


Q.13: What is parameter of function?
Ans.
A function is a block of statements that gets some inputs and provides some output. Inputs of a function are called parameters of the function.


Q.14: What do you mean by return value of a function?
Ans.
A function is a block of statements that gets some inputs and provides some output. Output of the function is called its return value. A function can have multiple parameters, but it cannot return more than one values.


Q.15: Write down the general structure of a function signature.
Ans.
The general structure of a function signature is as follows:


Q.16: What is int square(int); functions signature?
Ans.
A function that take an integer as input and returns its square.


Q.17: What is int float perimeter (float, float); functions signature?
Ans.
This function that takes length and width of a rectangle as input and returns the perimeter of
the rectangle.


Q.18: What is int largest (int, int, int); functions signature?
Ans.
A function that takes three integers as input and returns the largest value among them.


Q.19: What is float area (float); functions signature?
Ans.
A function that takes radius of a circle as input and returns the area of circle.


Q.20: What is int isvowel (char); functions signature?
Ans.
A function that takes a character as input and returns 1, if the character is vowel, otherwise return 0.


Q.21: What is the general structure of defining a Function?
Ans.
The function signature does not describe how the function performs the task assigned to it. Function definition does that. A function definition has the following general structure.
return_typefunction_name (data_type_var1, date_type var2, ….,data_type varN)
{
Body of the function
}


Q.22: Write down the example to define the function.
Ans.
Following example defines a function showPangram() that does not take any input and does not return anything, but displays “A quick brown fox jumps over the lazy dog”. on computer screen.


Q.23: Can function return more than one values?
Ans.
No, a function cannot return more than one values.


Q.24: Write down the general structure to make a function call?
Ans.
Following is the general structure used to make a function call. Function_name(value1, value2, …, valueN);


Q.25: Define arguments?
Ans.
The values passed to the function are called arguments.


Q.26: Differentiate between arguments and parameters of the function.
Ans.
The values passed to the function are called arguments, whereas variables in the function definition that receive these values are called parameters of the function.


Q.27: Which points are important for the arrangement of functions in a program?
Ans.
Following point must be kept in mind for the arrangement of functions in a program:
If the definition of called function appears before the definition of calling function, then function signature is not required.
If the definition of called function appears after the definition of calling function, then
function signature of called function must be written before the definition of calling
function.


Q.28: How many arguments can be used in a function?
Ans.
C language doesn’t put any restriction on number of arguments but arguments greater than 8 are not preferred.


Q.29: What is the output of the following program?
main()
{
int x=20;
int y=10;
swap(x,y);
printf(“%d %d”,y,x+2);
}
swap(int x, int y)
{
int temp;
temp =x;
x=y;
y=temp;
}


Q.30: What will be the output of the following code ?
output()
{
printf(“%p”,output);
}
Ans:Some address will be printed as function names are just addresses. Similarly output() is also a function and its address will be printed.


Q.31: What will be the output of the following code? ing code?
main()
{
int i;
printf(“%d”,scanf(“%d”,&i)); // value 10 is given as input here
}
Ans.1 as scanf returns number of items read successfully. So number of items read is 1.


Q.32: What will be the output of the C program?

int main()
{
function();
return 0;
}
void function()
{
printf(“Function in C is awesome”);
}
Output: Compilation error.

Q.33: What will be the error of the C program?
void message ();
{
printf (“Hope you are fine:”);
return 23;
Errors: After function definition there is no semicolon.


Q.34: What will be the error of the C program?
int max (int a, int b)
{
if (a > b)
return a;
}
return b;
Errors: Between parameters use comma instead of semicolon

Multiple Choice Questions

MCQs

1. A good approach is to divide the problem into multiple smaller parts of sub-problems.
A. functional
B. problem solving✅
C. definition a problem
D. none


2. The step to divide large problem into small problems is called
A. Divide and conquer✅
B. Dividing a problem
C. Searching a problem
D. Analyzing a problem


3. A is a block of statements which performs a particular task, is another function that is used to take input from the user.
A. Computer
B. program
C. function✅
D. Parameters


4. is a function that is used to display anything on computer screen,
A. Printf
B. scanf
C. getch
D. printf✅


5. is another function that is used to take input from the user.
A. scanf✅
B. getch
C. printf
D. int


6 Types of function in C language_
A. Built in Function
B. Both A and C✅
C. User defined function
D. None


7. Which one from the following is not type of function?
A. Built in Function
B. User defined function
C. Pre- defined function
D. C is not type of function✅


8. The functions which are available in C Standard Library are called
A. User defined fiction
B. Pre- defined function
C. built-in functions✅
D. All


9. Which functions used to perform mathematical calculations, string operations, input/output operations etc?
A. Built-in functions✅
B. User defined fiction
C. Pre- defined function
D. None


10. printf and scan are
A. Constant function
B. Argument s function
C. user- defined functions
D. Built-in functions✅


11. The functions which are defined by a programmer are called
A. library function
B. User defined fiction✅
C. one two function
D. returning function


12. What are the advantages of a functions?
A. Reusability
B. Separation of task
C. Readability
D. All✅


13. Which one from the following is not a advantage of a function?
A. Handling the complexity of the problem
B. Reusability
C. Accessibility✅
D. Readability


14. functions provide reusability of code.
A. Reusability✅
B. Readability
C. Separation of task
D. none


15. functions allow us to separate the code of one task from the code of other tasks.
A. Separation of problems
B. Separation of task✅
C. Alteration of code
D. Separation of function


16. divide the program into smaller units, and thus reduce the complexity of the problem.
A. programmer
B. variables
C. Functions✅
D. statements

17. Dividing the program into multiple functions, improves the _of the program,
A. Complicity
B. Reusability
C. Accessibility
D. Readability✅


18. Inputs of a function are called of the function.
A. parameters✅
B. value
C. Index
D. subscript


19. Output of the function is called its
A. index value
B. input value
C. return value✅
D. output value


20. is used to define the inputs and output of a function.
A. Function index
B. Function signature
B. Function value✅
C. Function uses


21. What are the examples of function signature?
A. int square (int);
B. float area (float);
C. int largest (int, int, int);
D. All✅


22. A function that takes an integer as input and returns its square, its function signature is
A. int square (int);✅
B. int largest (int, int, int);
C. int is Vowel (char);
D. float area (float);


23. A function that takes length and width of a rectangle as input and returns the perimeter of the rectangle, its function signature is
A. float area (float);
B. int is Vowel (char);
C. float perimeter (float, float);✅
D. None


24. A function that takes three integers as input and returns the largest value among them, its function signature is
A. int is Vowel (char);
B. int largest (int, int int);✅
C. int square (int);
D. float area (float);


25. A function that takes radius of a circle as input and returns the area of circle, its function signature is
A. float area (float);✅
B. int is Vowel (char);
C. int is Vowel (char);
D. All


26 A function that takes a character as input and retunes 1, if the character is vowel, otherwise return 0, its function signature is
A. char area (float);
B. float area (float);
C. int isVowel (char);✅
D. All

27. is the set of statements which are executed in the functions to perform the specified task.
A. Body of the function✅
B. Set of function
C. Header of function
D. None


28. A function cannot return more than values.
A. One✅
B. Two
C. Three
D. Four


29. Following is the general structure used to make a function call.
A. Function_bod y{value1, value2,. valueN};
B. Function_ name (value1, value2, valueN):✅
C. Function_ name{value 1, value2,, value3};
D. Function (value1, value2,. valueN};


30. The values passed to the function are called
A. terminator
B. functions
C. statement
D. arguments✅


31. Variables in the function definition that receive the values are called of the function.
A. Asuperscript
B. Bsubscript
C. Cparameters✅
D. Dindex

Related Articles

Back to top button
error: Content is protected !!
Enable Notifications OK No thanks