12th Computer Science Chapter 1 Reduced Guide
1. FUNCTIONS
Section – A
Choose the best answer (1 Mark)
1. The small sections of code that are used to perform a particular task is called
(A) Subroutines
(B) Files
(C) Pseudo code
(D) Modules
2. Which of the following is a unit of code that is often defined within a greater code structure?
(A) Subroutines
(B) Function
(C) Files
(D) Modules
3. Which of the following is a distinct syntactic block?
(A) Subroutines
(B) Function
(C) Definition
(D) Modules
4. The variables in a function definition are called as
(A) Subroutines
(B) Function
(C) Definition
(D) Parameters
5. The values which are passed to a function definition are called
(A) Arguments
(B) Subroutines
(C) Function
(D) Definition
6. Which of the following are mandatory to write the type annotations in the function definition?
(A) Curly braces
(B) Parentheses
(C) Square brackets
(D) indentations
Section-B
Answer the following questions (2 Mark)
1. What is a subroutine?
- Subroutines are the basic building blocks of computer programs.
- Subroutines are small sections of code that are used to perform a particular task that can be used repeatedly.
2. Define Function with respect to Programming language.
- A function is a unit of code that is often defined within a greater code structure.
- A function works on many kinds of inputs and produces a concrete output
3. Write the inference you get from X:=(78).
- X:=(78) is a function definition.
- Definitions bind values to names.
- Hence, the value 78 bound to the name „X‟.
Section - D
Answer the following questions: (5 Mark)
1. Parameter Without Type:
- The precondition (requires) and postcondition (returns) of the function is given.
- We have not mentioned any types: (data types). This is called parameter without type.
- In the above function definition the expression has type ‘int’, so the function's return type also be ‘int’ by implicit.
2. Parameter With Type:
- In this example we have explicitly annotating the types of argument and return type as ‘int’.
- Here, when we write the type annotations for „a‟ and „b‟ the parantheses are mandatory.
- This is the way passing parameter with type which helps the compiler to easily infer them.
No comments:
Post a Comment