Kerala Plus One Computer Science Chapter 10 Functions Questions and Answers

Solutions for Class 11 Computer Science: Chapter 10 Functions

Explore reliable textbook solutions for Chapter 10 Functions tailored for Class 11 learners. Utilizing these Computer Science answers ensures thorough preparation and strengthens foundational knowledge before final Kerala Board evaluations.

Practice Class 11 Computer Science Solutions: Chapter 10 Functions

Access the complete solution PDF for Class 11 Computer Science below. Regular practice with these targeted textbook answers builds familiarity with standard question patterns and helps secure higher marks in final school evaluations.

One Mark Questions and Answers

Question 1: The process of dividing big programs into small programs is called __________.

Answer:

Modularization

Exam Tips:

a) Modularization makes a program easier to write, read, debug and reuse; remember the word along with this idea.

 

Question 2: Big programs are divided into smaller programs. These smaller programs are called __________.

Answer:

Functions (also called modules or sub programs)

Exam Tips:

a) In C++, the small programs created by modularization are called functions.

 

Question 3: The execution of a C++ program begins at the __________ function.

Answer:

main() function

Exam Tips:

a) Every C++ program must have exactly one main() function; execution starts and normally ends there.

 

Question 4: Which one of the following is not involved in the creation and usage of a user defined function?
(a) Define a function
(b) Declare a function
(c) Invoke a function
(d) None of these

Answer:

(d) None of these

Exam Tips:

a) All three steps (declaration, definition and calling) are part of using a user defined function, so none of them can be left out.

 

Question 5: The default data type returned by a function is ________.
(a) float
(b) double
(c) int
(d) char

Answer:

(c) int

Exam Tips:

a) If no return type is written, older C++ compilers assume int; always write the return type yourself to avoid confusion.

 

Question 6: After the execution of a function, control goes back to the calling function by executing the _________ keyword.

Answer:

return

Exam Tips:

a) return sends control (and a value, if any) back to the place from where the function was called.

 

Question 7: Data is supplied to a function from the calling function by using _________.

Answer:

Parameters (arguments)

Exam Tips:

a) The calling function supplies arguments; the called function receives them as parameters.

 

Question 8: The _________ keyword is used to give a value back to the calling function.

Answer:

return

Exam Tips:

a) A function can return only one value using a return statement.

 

Question 9: The _________ keyword is used to specify that a function returns nothing.

Answer:

void

Exam Tips:

a) A void function can still use "return;" without a value to stop its execution early.

 

Question 10: Which one of the following is not necessary in a function declaration?
(a) Name of the function
(b) Return type
(c) Number and type of arguments
(d) Name of the parameters

Answer:

(d) Name of the parameters

Exam Tips:

a) A prototype such as int sum(int, int); is valid without parameter names; only the types are needed.

 

Question 11: A function declaration is also called a _________.

Answer:

Prototype (function prototype)

Exam Tips:

a) The prototype tells the compiler the return type, name and argument types before the function is used.

 

Question 12: Consider the following function definition.
int sum(int a, int b)
{
return a+b;
}
Which of the following is a valid function call?
(a) n = sum(10)
(b) n = sum(10,20)
(c) n = sum(10,20,30)
(d) n = sum()

Answer:

(b) n = sum(10,20)

Exam Tips:

a) The number of arguments in the call must match the number of parameters, unless default arguments are given.

 

Question 13: The ability to access a variable or a function from some part of a program is called ________.

Answer:

Scope

Exam Tips:

a) Scope tells where a variable or function can be used; life tells how long it exists in memory.

 

Question 14: A variable or a function declared within a function has ______ scope.

Answer:

Local

Exam Tips:

a) A local variable can be used only inside the function (block) in which it is declared.

 

Question 15: A variable or a function declared outside all the functions has __________ scope.

Answer:

Global

Exam Tips:

a) A global variable can be used by every function written after its declaration.

 

Question 16: State True or False.
1. A local variable exists till the end of the program.
2. A global variable is destroyed when the sub function terminates.

Answer:

1. False
2. False

Exam Tips:

a) A local variable is destroyed when its block or function ends.
b) A global variable exists till the end of the program.

 

Question 17: Consider the following code.
int x;
void main()
{
........
}
Here x is a _____ variable.

Answer:

Global

Exam Tips:

a) x is declared outside all functions, so it is global.

 

Question 18: Consider the following code.
void main()
{
int x;
}
Here x is a _______ variable.

Answer:

Local

Exam Tips:

a) x is declared inside main(), so it can be used only within main().

 

Question 19: A __________ parameter is used when the function call does not supply a value for a parameter.

Answer:

Default

Exam Tips:

a) Default values are given in the prototype from right to left, for example int add(int a, int b = 0);

 

Question 20: The parameters used in a function call are called ____________.

Answer:

Actual parameters (arguments)

Exam Tips:

a) Actual parameters appear in the call statement; formal parameters appear in the function definition.

 

Question 21: The parameters that appear in a function definition are called ___________.

Answer:

Formal parameters

Exam Tips:

a) Do not mix up actual and formal parameters; this is a common one-mark question.

 

Question 22: After the answer scripts are distributed, the teacher gives a photostat copy of the mark list to the students to check the marks. Any change made by the students does not affect the original mark list. There is a similar method to pass arguments to a function. What is this method?
(a) Call by value
(b) Call by reference
(c) Call by address
(d) None of these

Answer:

(a) Call by value

Exam Tips:

a) In call by value, the function works on a copy, so the original variable is not changed.

 

Question 23: Your class teacher gives you the original mark list to check the marks. Any change you make will affect the original mark list. There is a similar method to pass arguments to a function. What is this method?
(a) Call by value
(b) Call by reference
(c) Call by function
(d) None of these

Answer:

(b) Call by reference

Exam Tips:

a) In call by reference, the function works on the original variable, so changes are seen in the calling function.

 

Question 24: Consider the following function definition.
int sum(int a, int b)
{
Body
}
Here the arguments are passed by the __________ method.

Answer:

Call by value method

Exam Tips:

a) No & symbol before the parameter names means the arguments are passed by value.

 

Question 25: Consider the following function definition.
int sum(int &a, int &b)
{
Body
}
Here the arguments are passed by the __________ method.

Answer:

Call by reference method

Exam Tips:

a) The & symbol before the parameter name makes it a reference parameter.

 

Question 26: A function that calls itself is known as a ____________.

Answer:

Recursive function

Exam Tips:

a) A recursive function must have a stopping condition (base case); otherwise it calls itself endlessly.

 

Question 27: Varun wants to copy a string using the strcpy() function. Which header file is needed for this?
(a) cstdio
(b) cmath
(c) cstring
(d) cctype

Answer:

(c) cstring

Exam Tips:

a) String functions such as strcpy(), strcat(), strlen() and strcmp() are in cstring.

 

Question 28: A __________ is a named group of statements that performs a job/task and returns a value.

Answer:

Function

Exam Tips:

a) Remember the key words of the definition: named group of statements, a specific task, returns a value.

 

Question 29: In his C++ program, Ajith wants to accept a lengthy text of more than one word. Which function in C++ can be used in this situation?

Answer:

The gets() function can be used to accept a lengthy text with spaces.

Exam Tips:

a) cin>> stops reading at a space, so it cannot read a sentence; gets() (or cin.getline()) reads the whole line.

 

Question 30: A function can call itself many times and return a result. What is the name given to such a function?

Answer:

Recursive function

Exam Tips:

a) One-word answers like this must be spelt correctly.

 

Question 31: How many values can a C++ function return?

Answer:

One value

Exam Tips:

a) A function returns only one value with return; to send back more values, use reference parameters.

 

Question 32: A function may require data to perform the task assigned to it. Which component of the function prototype serves this purpose?

Answer:

Arguments (parameters)

Exam Tips:

a) A prototype has three parts: return type, function name and argument list. The argument list carries the data.

 

Question 33: "Arguments used in a call statement are formal arguments." State true or false.

Answer:

False. Arguments used in a call statement are actual arguments.

Exam Tips:

a) Correct the statement when you write False; it shows you know the reason.

 

Question 34: Name the built-in function used to check whether a character is alphanumeric or not.

Answer:

isalnum()

Exam Tips:

a) isalnum() is in the cctype header file and returns a non-zero value for a letter or a digit.

 

Two Mark Questions and Answers

Question 35: How does C++ support modularity in programming?

Answer:

Dividing a big program into smaller programs is called modularisation. These small programs are called modules, sub programs or functions.
C++ supports modularity through functions. Each task is written as a separate function, and these functions are called from main() or from other functions.

Exam Tips:

a) Define modularisation first and then say that C++ achieves it using functions.
b) Mention one advantage, such as easy debugging or code reuse, if you have time.

 

Question 36: Consider the following code snippet.
char ch;
cout << "Enter an alphabet";
cin >> ch;
cout << (char)toupper(ch);
What is the output of the above code? Give a sample output.
If the above code is used in a computer that has no cctype header file, how will you modify the code to get the same output?

Answer:

The code reads a character and displays it in upper case.
Sample run:
Enter an alphabet: a
Output: A
Without the cctype header file, the conversion can be done using ASCII values (a to z are 97 to 122, A to Z are 65 to 90):
char ch;
cout << "Enter an alphabet";
cin >> ch;
if (ch >= 97 && ch <= 122)
ch = ch - 32;
cout << ch;

Exam Tips:

a) The ASCII value of a lower case letter is 32 more than its upper case form.
b) Store the converted value in a char variable before printing; cout << ch - 32 prints an integer, not a letter.

 

Question 37: The following assignment statement will generate a compilation error.
char str[20];
str = "Computer";
Write a correct C++ statement to perform the same task.

Answer:

char str[20] = "Computer";
OR
char str[20];
strcpy(str, "Computer");
(The header file cstring should be included for strcpy().)

Exam Tips:

a) A string cannot be assigned to an array with = after declaration; it can only be initialised during declaration or copied with strcpy().

 

Question 38: Consider the following function.
float area(const float pi = 3.1415, const float r)
{
r = 10;
return pi*r;
}
Is there any problem? If yes, what is it?

Answer:

Yes, there are errors.
1. r is declared as a constant argument, so its value cannot be changed inside the function. The statement r = 10; is an error.
2. pi has a default value but r, which is on its right side, has no default value. Default arguments must be given from right to left, so this is also an error.
(Also, the area of a circle should be pi*r*r, not pi*r.)

Exam Tips:

a) Check two rules in such questions: a const argument cannot be modified, and default values must be assigned from right to left.

 

Question 39: Match the following.
a. strcmp() — 1. cctype
b. tolower() — 2. iomanip
c. sqrt() — 3. cstring
d. abort() — 4. cstdlib
e. setw() — 5. cmath

Answer:

a. strcmp() – 3. cstring
b. tolower() – 1. cctype
c. sqrt() – 5. cmath
d. abort() – 4. cstdlib
e. setw() – 2. iomanip

Exam Tips:

a) Group header files by type: string functions in cstring, character functions in cctype, maths functions in cmath.
b) Write the function name with the matched header, not only the numbers.

 

Question 40: What are the jobs of a return statement in a program?

Answer:

In a sub function, the return statement ends the function and takes control back to the calling function (for example main()). It can also send a value back to the calling function.
In the main() function, the return statement ends the program.

Exam Tips:

a) Mention both jobs: ending the function and returning a value.

 

Question 41: How is a function invoked in a C++ program?

Answer:

A function is called (invoked) by writing the name of the function followed by the arguments inside parentheses.
Example: sum(m, n);
If the function returns a value, the call can be used in an expression, for example s = sum(m, n);

Exam Tips:

a) Always give an example call statement with the explanation.

 

Question 42: Briefly explain constant arguments.

Answer:

A function argument (parameter) can be made constant by using the keyword const. The value of a const argument cannot be modified inside the function.
Example: float area(const float pi, float r);

Exam Tips:

a) Give an example declaration using const; it makes the answer complete.

 

Question 43: Write short notes on header files.

Answer:

A header file is a stored file that contains the declarations of built-in functions and objects. Header files are needed to use these functions in a C++ program.
Some header files are:
iostream
iomanip
cstdio
cctype
cmath
cstring
cstdlib
The syntax for including a header file is:
#include<name of the header file>
Example: #include<iostream>

Exam Tips:

a) List at least four header files and write the #include syntax with an example.

 

Question 44: Identify the appropriate header files for the following.
1. setw()
2. cout
3. toupper()
4. exit()
5. strcpy()

Answer:

1. setw() – iomanip
2. cout – iostream
3. toupper() – cctype
4. exit() – cstdlib
5. strcpy() – cstring

Exam Tips:

a) toupper() works on a single character, so it is in cctype, not cstring.
b) exit() is in cstdlib (stdlib.h in older compilers).

 

Question 45: Construct the function prototypes for the following functions.
1. The function Display() accepts one argument of type double and does not return any value.
2. Total() accepts two arguments of type int and float respectively and returns a float type value.

Answer:

1. void Display(double);
2. float Total(int, float);

Exam Tips:

a) A prototype ends with a semicolon.
b) Parameter names are optional in a prototype; the types are enough.

 

Question 46: Explain two types of variables according to their scope and life.

Answer:

1. Local variable (local scope):
A variable declared inside a block or function can be used only in that block. It is created when the block starts and destroyed when the block ends.
Example:
#include<iostream>
using namespace std;
int sum(int n1, int n2)
{
int s;
s = n1 + n2;
return (s);
}
int main()
{
int n1, n2;
cout << "Enter 2 numbers";
cin >> n1 >> n2;
cout << "The sum is " << sum(n1, n2);
}
Here the variable s is declared inside the function sum(), so it has local scope.
2. Global variable (global scope):
A variable declared outside all the functions can be used anywhere in the program. It exists till the program ends.
Example:
#include<iostream>
using namespace std;
int s;
int sum(int n1, int n2)
{
s = n1 + n2;
return (s);
}
int main()
{
int n1, n2;
cout << "Enter 2 numbers";
cin >> n1 >> n2;
cout << "The sum is " << sum(n1, n2);
}
Here the variable s is declared outside all functions, so it can be used anywhere in the program.

Exam Tips:

a) For each type, state where it is declared, where it can be used (scope) and how long it exists (life).
b) A short example for each type earns full marks.

 

Question 47: There is a way to pass more than one value back to the calling function from the called function. Explain how.

Answer:

More values can be sent back by using the call by reference method. In this method, the called function works on the original variables, so all the changes it makes are seen in the calling function.
The two methods of calling functions are:
1. Call by value:
A copy of the original value is passed to the function. Any change made by the function does not affect the original value.
Example:
#include<iostream>
using namespace std;
void swap(int a, int b)
{
int temp;
temp = a;
a = b;
b = temp;
}
int main()
{
int a, b;
cout << "Enter values for a and b: ";
cin >> a >> b;
cout << "The values before swap a = " << a << " and b = " << b;
swap(a, b);
cout << "\nThe values after swap a = " << a << " and b = " << b;
}
Here the values of a and b are not exchanged in main().
2. Call by reference:
The reference (address) of the original variable is passed to the function. Any change made by the function affects the original value.
Example:
#include<iostream>
using namespace std;
void swap(int &a, int &b)
{
int temp;
temp = a;
a = b;
b = temp;
}
int main()
{
int a, b;
cout << "Enter values for a and b: ";
cin >> a >> b;
cout << "The values before swap a = " << a << " and b = " << b;
swap(a, b);
cout << "\nThe values after swap a = " << a << " and b = " << b;
}
Here both a and b are changed in main(), so two values come back from the function.

Exam Tips:

a) The key answer is "call by reference"; say it in the first line.
b) Use the swap() example: it changes two variables at once, which a single return statement cannot do.

 

Question 48: Write a function definition that accepts two integers N and Start_No and returns the sum of N consecutive numbers starting from Start_No.

Answer:

int sum(int N, int Start_No)
{
int i, S = 0;
for (i = Start_No; i < N + Start_No; i++)
S = S + i;
return S;
}
For example, sum(3, 5) returns 5 + 6 + 7 = 18.

Exam Tips:

a) Check the loop limits with a small example such as N = 3; an off-by-one error is the most common mistake.
b) Initialise the sum variable S to 0 before the loop.

 

Question 49: Differentiate between the string functions strcmp() and strcmpi().

Answer:

strcmp(): It compares two strings and returns an integer.
Syntax: strcmp(string1, string2)
If the result is 0, both strings are equal.
If the result is greater than 0 (positive), string1 is greater than string2.
If the result is less than 0 (negative), string2 is greater than string1.
strcmpi(): It works like strcmp(), but it is not case sensitive. Upper case and lower case letters are treated as the same.
Example: "ANDREA", "Andrea" and "andrea" are equal for strcmpi().

Exam Tips:

a) The key difference is case sensitivity; give an example where strcmp() and strcmpi() give different results.

 

Question 50: Read the function definition given below. Predict the output if the function is called as convert(7).
void convert(int n)
{
if (n>1)
convert(n/2);
cout << n%2;
}

Answer:

The output is 111.
convert() is a recursive function. convert(7) calls convert(3), which calls convert(1). convert(1) prints 1 % 2 = 1. Then convert(3) prints 3 % 2 = 1 and convert(7) prints 7 % 2 = 1.
The function prints the binary form of 7, which is 111.

Exam Tips:

a) Trace recursive calls step by step; output is printed while the calls return, in reverse order.
b) Recognise the pattern: this function prints the binary equivalent of n.

 

Three Mark Questions and Answers

Question 51: Consider the following function declarations with optional (default) arguments. State whether each is legal or illegal and give the reason.
1. int sum(int x = 10, int y, int z)
2. int sum(int x = 10, int y = 20, int z)
3. int sum(int x = 10, int y = 20, int z = 30)
4. int sum(int x, int y = 20, int z)
5. int sum(int x, int y = 20, int z = 30)
6. int sum(int x, int y, int z = 30)
7. int sum(int x = 10, int y, int z = 30)

Answer:

Rule: default values must be given from right to left. An argument can have a default value only if all the arguments on its right side also have default values.
1. Illegal, because y and z do not have default values.
2. Illegal, because z has no default value.
3. Legal
4. Illegal, because z has no default value.
5. Legal
6. Legal
7. Illegal, because x has a default value but y has none.

Exam Tips:

a) Write the right-to-left rule first; it carries a mark on its own.
b) For each illegal case, name the argument that is missing a default value.

 

Question 52: A list of C++ built-in functions is given. Classify them based on their usage and prepare a table with proper group names.
strcmp(), sin(), getch(), isalpha(), pow(), puts(), strcat(), tolower(), getchar(), isalnum(), sqrt(), exp(), write()

Answer:

String functionsMathematical functionsCharacter functionsI/O functions
strcmp()sin()isalpha()getch()
strcat()pow()isalnum()puts()
sqrt()tolower()getchar()
exp()write()

Exam Tips:

a) Use clear group names as table headings: string, mathematical, character and I/O functions.
b) Check that every function in the list appears once in the table.

 

Question 53: Read the following program.
#include<iostream>
using namespace std;
int main()
{
cout << sum(2,3);
}
int sum(int x, int y)
{
return (x + y);
}
When this program is compiled, an error is displayed. Identify and explain the reason. How can you rectify the problem?

Answer:

The compiler reads the program line by line from the top. When it reaches cout << sum(2,3); it does not know the function sum(), because it has not been declared yet. So an error (function not declared / prototype required) is shown.
There are two ways to correct it.
First method: Write the function definition before main().
#include<iostream>
using namespace std;
int sum(int x, int y)
{
return (x + y);
}
int main()
{
cout << sum(2,3);
}
Second method: Give the function declaration (prototype) before the call, for example inside main().
#include<iostream>
using namespace std;
int main()
{
int sum(int, int);
cout << sum(2,3);
}
int sum(int x, int y)
{
return (x + y);
}

Exam Tips:

a) Use the word "prototype" or "declaration" when explaining the error.
b) Give both methods of correction; each one carries marks.

 

Question 54: Consider the following program.
int fact(int &n)
{
int f = 1;
for ( ; n>0; n--)
f = f*n;
return f;
}
void main()
{
int a = 5, ans;
ans = fact(a);
cout << a << "! = " << ans;
}
The expected output is 5! = 120. What will be the actual output of the program? Why is it not the same? What modification is required to get the desired output?

Answer:

The actual output is 0! = 120
The variable a is passed to the function by reference (int &n). So n is another name for a. The loop decreases n till it becomes 0, so the value of a in main() also becomes 0.
To get the desired output, pass the argument by value. Change the function header from int fact(int &n) to int fact(int n), that is, remove the & symbol. Then the function works on a copy, and a stays 5.

Exam Tips:

a) Whenever you see & in a parameter, check whether the function changes that variable; the change is seen in main().
b) State the output, the reason and the correction separately.

 

Question 55: A function is defined as follows.
int sum(int a, int b = 2)
{
return (a + b);
}
Check whether each of the following function calls is correct or wrong. Justify your answer.
1. cout << sum(2,3);
2. cout << sum(2);
3. cout << sum();

Answer:

The function has one default argument (b), so at least one argument must be given in the call.
1. Correct. a becomes 2 and b becomes 3. Output is 5.
2. Correct. a becomes 2 and b takes the default value 2. Output is 4.
3. Wrong. There is no value for a, and a has no default value.

Exam Tips:

a) Write the output value for each valid call; it shows you understood how default arguments work.

 

Question 56: The factorial of a number N is the product of the first N natural numbers. The factorial of 5 can be found by multiplying 5 and the factorial of 4. Similarly, the factorial of 4 can be found by multiplying 4 and the factorial of 3. At last, the factorial of 1 is 1 itself.
Which technique is used to find the factorial of a number in this way? Write a C++ function to implement this technique. Also explain the working of the function by giving 5 as input.

Answer:

The technique is recursion. A function that calls itself is called a recursive function.
#include<iostream>
using namespace std;
int fac(int);
int main()
{
int n;
cout << "Enter a number";
cin >> n;
cout << fac(n);
}
int fac(int n)
{
if (n == 1)
return (1);
else
return (n * fac(n - 1));
}
Working: When n = 5, the call fac(5) returns 5 * fac(4). fac(4) returns 4 * fac(3), and this continues until fac(1), which returns 1.
So the result is 5 * 4 * 3 * 2 * 1 = 120.

Exam Tips:

a) Every recursive function needs a base case, here n == 1, to stop the calls.
b) Show the chain of calls fac(5) to fac(1) for full marks.

 

Question 57: How do two functions exchange data between them? Compare the two methods of data transfer from the calling function to the called function.

Answer:

Functions exchange data through arguments (parameters) and return values. There are two methods to pass arguments.
1. Call by value: A copy of the actual parameters is passed to the formal parameters. Any change made by the function does not affect the original values.
2. Call by reference: A reference to the actual parameters is passed to the formal parameters. Any change made by the function affects the original values.

Exam Tips:

a) A small table comparing the two methods (copy vs reference, original changed or not, & symbol used or not) is easy to score with.

 

Question 58: Read the following program.
#include<iostream>
using namespace std;
int a = 0;
int main()
{
int showval(int);
cout << a;
a++;
cout << showval(a);
cout << a;
}
int showval(int x)
{
int a = 5;
return (a + x);
}
Write down the output of the above program with a suitable explanation. What inferences can be drawn regarding the scope of variables?

Answer:

The output is 061
Global variable: A variable declared outside all functions.
Local variable: A variable declared inside a function.
If a function has a local variable with the same name as a global variable, the function uses its local variable.
Here, int a = 0 is a global variable. main() has no local a, so it uses the global a and prints 0. Then a++ makes it 1.
showval(a) is called with x = 1. Inside showval(), the local a (value 5) is used, so the function returns 5 + 1 = 6, which is printed.
Finally, main() prints the global a, which is 1.
So the output is 061.
Inference: a local variable hides a global variable of the same name inside that function.

Exam Tips:

a) Trace each cout one by one and write the printed value next to it.
b) State the inference about local and global variables clearly; it is a separate part of the question.

 

Question 59: The following are function calling statements. Some of them will be executed, while others will generate compilation errors. Write your opinion on each of them with proper justification.
1. char ch = getch();
2. sqrt(25);
3. strcat("Computer", "Program");
4. double num = pow(2,3,5);
5. putchar(getchar());

Answer:

1. It will be executed (conio.h is needed). getch() reads a character from the keyboard without showing it on the screen, and the character is stored in ch.
2. It will be executed. It finds the square root of 25, but the result (5) is not stored or displayed.
3. It is an error. strcat() adds the second string to the end of the first, so the first argument must be a character array with enough space. A string constant like "Computer" cannot be changed.
4. It is an error. pow() takes only two arguments, but three are given here. It can be written as double num = pow(pow(2,3),5);
5. It will be executed. It reads a character from the keyboard and displays it on the screen.

Exam Tips:

a) For each statement, say clearly "executed" or "error" and then give the reason.
b) Remember the argument count of common functions: pow() needs two, sqrt() needs one.

 

Question 60: Write down the operation performed by the following statements.
1. int l = strlen("Computer Program");
2. char ch[ ] = tolower("My School");
3. cout << (strcmp("High", "Low")>0 ? toupper("High") : tolower("Low"));

Answer:

1. strlen() finds the length of the string, which is 16 (including the space). The value 16 is stored in the variable l.
2. This is an error, because tolower() is a character function. It works on a single character, not on a string.
3. This is also an error, because toupper() and tolower() are character functions and cannot take strings.

Exam Tips:

a) Count the space too when finding the length of a string with strlen().
b) Remember: functions in cctype work on single characters only.

 

Question 61: A line of given length with a particular character is to be displayed. For example, ********** is a line with ten asterisks (*). Define a function to get this output.

Answer:

#include<iostream>
using namespace std;
void line(char ch, int n)
{
int i;
for (i = 0; i < n; i++)
cout << ch;
}
int main()
{
char ch;
int n;
cout << "Enter a character ";
cin >> ch;
cout << "Enter how many number of times";
cin >> n;
line(ch, n);
}
For example, line('*', 10); displays **********

Exam Tips:

a) Pass both the character and the length as arguments so that the function works for any line.
b) A void function is enough because nothing needs to be returned.

 

Question 62: Read the following function.
int fib(int n)
{
if (n<3)
return 1;
else
return (fib(n - 1) + fib(n - 2));
}
1. What is the speciality of this function?
2. How does it work?
3. What will be the output of the following code?
for (int i = 1; i <= 4; i++)
cout << fib(i) << " ";

Answer:

1. It is a recursive function, that is, the function calls itself.
2. It works as follows:
When i = 1, fib(1) returns 1.
When i = 2, fib(2) returns 1.
When i = 3, fib(3) returns fib(2) + fib(1) = 1 + 1 = 2.
When i = 4, fib(4) returns fib(3) + fib(2) = 2 + 1 = 3.
3. The output is 1 1 2 3

Exam Tips:

a) This function produces the Fibonacci series; mention it to show understanding.
b) Trace values from small n upwards, since fib(3) and fib(4) use the earlier results.

 

Question 63: Explain the scope rules of functions and variables in a C++ program.

Answer:

Local variable or function:
A variable or function declared inside a function is called a local variable or function. It cannot be accessed from outside that function.
Example:
main()
{
int k; // local variable
int sum(int, int); // local function declaration
cout << sum(a, b);
}
Global variable or function:
A variable or function declared outside all functions is called a global variable or function. It can be accessed by any statement in the program.
Example:
int k; // global variable
int sum(int a, int b); // global function
main()
{
}

Exam Tips:

a) Give one example each for local and global scope.
b) Use comments like // local variable in the example to point out each item.

 

Question 64: Briefly explain default arguments.

Answer:

A default value can be given to a parameter (argument) of a function. When the call does not give a value for that parameter, the function uses the default value.
Important rule: an argument can have a default value only if all the arguments on its right side also have default values.
Functions with valid default arguments:
float area(int x, int y, int z = 30);
float area(int x, int y = 20, int z = 30);
float area(int x = 10, int y = 20, int z = 30);
Functions with invalid default arguments:
float area(int x = 10, int y, int z);
float area(int x, int y = 20, int z);
float area(int x = 10, int y = 20, int z);

Exam Tips:

a) Give at least one valid and one invalid example along with the right-to-left rule.

 

Question 65: How is an array passed to a function?

Answer:

An array is passed to a function by giving only the array name in the call. The array name holds the starting address of the array, so the function can access all the elements. So arrays work like call by reference.
Example:
#include<iostream>
using namespace std;
void sum(int m[], int k)
{
int total = 0;
for (int i = 0; i < k; i++)
total = total + m[i];
cout << "The total is " << total;
}
int main()
{
int n[5], i;
for (i = 0; i < 5; i++)
{
cout << "Enter the number" << i+1 << ":";
cin >> n[i];
}
sum(n, 5);
}

Exam Tips:

a) In the call, write only the array name, without square brackets: sum(n, 5).
b) Pass the number of elements as a separate argument.

 

Question 66: How is a structure passed to a function?

Answer:

A structure can be passed to a function by the call by value method or the call by reference method. The example below reads the name and age into a structure using call by reference and displays them using call by value.
#include<iostream>
using namespace std;
struct details
{
int age;
char name[10];
};
void read(details &n2)
{
cout << "Enter your name and age";
cin >> n2.name >> n2.age;
}
void disp(details n3)
{
cout << "Your name is " << n3.name << " and age is " << n3.age;
}
int main()
{
details d1;
read(d1);
disp(d1);
}

Exam Tips:

a) Use & for the function that changes the structure (reading values); call by value is enough for displaying.
b) Access members with the dot operator, for example n2.age.

 

Question 67: Write a program to read a character and check whether it is an alphabet or not. If it is an alphabet, check whether it is in upper case or lower case.

Answer:

#include<iostream>
using namespace std;
int main()
{
char ch;
cout << "Enter a character";
cin >> ch;
if (ch >= 65 && ch <= 90)
cout << "It is an upper case alphabet";
else if (ch >= 97 && ch <= 122)
cout << "It is a lower case alphabet";
else
cout << "It is not an alphabet";
}

Exam Tips:

a) You may also use isupper() and islower() from cctype; either method is accepted.
b) Remember the ASCII ranges: A–Z is 65–90 and a–z is 97–122.

 

Question 68: Write a program to read two strings and join them (without using a string function).

Answer:

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
char str1[50], str2[50], str[100];
int i, len1 = 0, len2 = 0;
cout << "Enter a string:";
gets(str1);
cout << "Enter another string:";
gets(str2);
for (i = 0; str1[i] != '\0'; i++, len1++);
for (i = 0; str2[i] != '\0'; i++, len2++);
for (i = 0; i < len1; i++)
str[i] = str1[i];
for (i = 0; i < len2; i++)
str[len1 + i] = str2[i];
str[len1 + len2] = '\0';
cout << "The concatenated string is " << str;
}

Exam Tips:

a) Do not forget to put '\0' at the end of the joined string.
b) The second string starts at position len1 in the new array.

 

Question 69: Write a program to read two strings and compare them.

Answer:

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
int m;
char str1[100], str2[100];
cout << "Enter first string";
gets(str1);
cout << "Enter second string";
gets(str2);
m = strcmp(str1, str2);
if (m < 0)
cout << str1 << " is less than " << str2;
else if (m > 0)
cout << str1 << " is greater than " << str2;
else
cout << str1 << " is equal to " << str2;
}

Exam Tips:

a) Check all three results of strcmp(): negative, positive and zero.
b) Include cstring for strcmp().

 

Question 70: Write a program to read a string and display the number of alphabets, digits and special characters.

Answer:

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
char str[100];
int i, digit = 0, alpha = 0, special = 0;
cout << "Enter a string:";
gets(str);
for (i = 0; str[i] != '\0'; i++)
if (str[i] >= 48 && str[i] <= 57)
digit++;
else if ((str[i] >= 65 && str[i] <= 90) || (str[i] >= 97 && str[i] <= 122))
alpha++;
else
special++;
cout << "The number of alphabets is " << alpha << ", the number of digits is " << digit << " and the number of special characters is " << special;
}

Exam Tips:

a) Digits 0–9 have ASCII values 48–57; use isdigit() and isalpha() if you find them easier.
b) Initialise all counters to 0.

 

Question 71: Write a program to perform the following operations on a string.
1. Length of a string
2. Search a character
3. Display the string

Answer:

#include<iostream>
#include<cstdio>
using namespace std;
void len()
{
char str[100];
int i, len;
cout << "Enter a string:";
gets(str);
for (i = 0, len = 0; str[i] != '\0'; i++, len++);
cout << "The length of the string is " << len;
}
void search()
{
char str[100], s;
int f = 0, i;
cout << "Enter a string:";
gets(str);
cout << "Enter the character to be searched";
cin >> s;
for (i = 0; str[i] != '\0'; i++)
if (str[i] == s)
f = 1;
if (f)
cout << "The character is present in the string";
else
cout << "The character is not present in the string";
}
void display()
{
char str[100];
cout << "Enter a string:";
gets(str);
cout << "The string you entered is " << str;
}
int main()
{
int ch;
do
{
cout << "\n1. Length of a string\n2. Search a character\n3. Display the string\nEnter the choice (zero for exit):";
cin >> ch;
cin.ignore();
switch (ch)
{
case 1: len(); break;
case 2: search(); break;
case 3: display(); break;
default: cout << "Thank you";
}
} while (ch != 0);
}

Exam Tips:

a) Write a separate function for each operation and call them from a menu using switch.
b) After cin >> ch, the Enter key stays in the input; clear it before using gets().

 

Question 72: Write short notes about conversion functions.

Answer:

The header file cstdlib (stdlib.h) contains the conversion functions. The important ones are:
1. itoa(): Converts an integer into a string.
Example:
int n = 100;
char str[20];
itoa(n, str, 10);
2. ltoa(): Converts a long integer into a string.
Example:
long n = 1002345L;
char str[20];
ltoa(n, str, 10);
3. atoi(): Converts a string into an integer.
Example:
int n;
char str[] = "123";
n = atoi(str);
4. atol(): Converts a string into a long integer.
Example:
long n;
char str[] = "123456";
n = atol(str);

Exam Tips:

a) Remember the naming pattern: a = ASCII (string), i = int, l = long; atoi means "ASCII to int".
b) The third argument 10 in itoa()/ltoa() is the base (decimal).

 

Question 73: Consider the two programs given below.
A.
void change(int &);
int main()
{
int x = 0;
change(x);
cout << "value =" << x;
}
void change(int &y)
{
y = 40;
cout << "value=" << y;
}
B.
void change(int);
int main()
{
int x = 0;
change(x);
cout << "value =" << x;
}
void change(int y)
{
y = 40;
cout << "value =" << y;
}
1. Predict the output of both programs.
2. Justify your predictions.

Answer:

1. Output of A: value=40value =40
Output of B: value =40value =0
2. In program A, x is passed by reference. So the change made to y in the function is also made to x in main(), and main() prints 40.
In program B, x is passed by value. The function changes only its copy y, so x in main() remains 0.

Exam Tips:

a) Both programs also print inside change(), so include that line in the output.
b) Point out the & symbol as the only difference between the two programs.

 

Question 74: Consider the following C++ function.
int recfact(int x)
{
if (x == 0)
return 1;
else
return x * recfact(x - 1);
}
1. What type of function is this? Explain.
2. What is the output of the above function when x = 5?

Answer:

1. It is a recursive function. The ability of a function to call itself is called recursion. A function is recursive if a statement in its body calls the same function.
2. The output is 120 (5 * 4 * 3 * 2 * 1 * 1).

Exam Tips:

a) Name the base case (x == 0 returns 1) when explaining a recursive function.

 

Question 75: Consider the following code.
void initialise()
{
int k = 10;
}
int main()
{
int a, b;
float marks;
a = 20;
cout << "First value =" << a;
initialise();
b = k + a;
cout << "New value =" << b;
}
1. Identify the error in the above code and explain its reason.
2. Correct the error.

Answer:

1. k is a local variable of the function initialise(). It cannot be accessed in main(), so the statement b = k + a; gives an error.
2. Declare k as a global variable (outside all functions), for example int k; before initialise(), and write k = 10; inside the function. Then main() can use k.

Exam Tips:

a) Local variables are visible only inside their own function; this is the most common reason for an "undeclared identifier" error.
b) When you make k global, remove the int from inside the function, or a new local k will be created.

 

Question 76: Write a program to read two strings and join them using a string function.

Answer:

#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
char str1[50], str2[50], str[100];
cout << "Enter a string:";
gets(str1);
cout << "Enter another string:";
gets(str2);
strcpy(str, str1);
strcat(str, str2);
cout << "The concatenated string is " << str;
}

Exam Tips:

a) strcat() adds to the end of an existing string, so the target must first contain a valid string (use strcpy() first).

 

Question 77: Consider the following code.
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
char str1[] = "123", str2[] = "45";
int a, b;
a = atoi(str1);
b = atoi(str2);
cout << a + b;
}
What will be the output? Give the reason.

Answer:

The output is 168.
atoi() converts the string "123" into the integer 123 and "45" into the integer 45. So a + b = 123 + 45 = 168.

Exam Tips:

a) Without atoi(), the strings could not be added as numbers; mention the conversion in your reason.

 

Question 78: Name the different methods used for passing arguments to a function. Write the difference between them with examples.

Answer:

There are two methods: call by value and call by reference.
1. Call by value: A copy of the original value is passed to the function. Any change made by the function does not affect the original value.
Example:
#include<iostream>
using namespace std;
void swap(int x, int y)
{
int temp;
temp = x;
x = y;
y = temp;
}
int main()
{
int a, b;
cout << "Enter 2 nos";
cin >> a >> b;
cout << "The values before swap a = " << a << " and b = " << b;
swap(a, b);
cout << "\nThe values after swap a = " << a << " and b = " << b;
}
There is no change in the values of a and b.
2. Call by reference: The reference (address) of the original value is passed to the function. Any change made by the function affects the original value.
Example:
#include<iostream>
using namespace std;
void swap(int &x, int &y)
{
int temp;
temp = x;
x = y;
y = temp;
}
int main()
{
int a, b;
cout << "Enter 2 nos";
cin >> a >> b;
cout << "The values before swap a = " << a << " and b = " << b;
swap(a, b);
cout << "\nThe values after swap a = " << a << " and b = " << b;
}
The values of a and b are exchanged.

Exam Tips:

a) Use the same swap() program for both methods; the only change is the & symbol, which makes the difference easy to show.
b) State the result (values changed or not) after each example.

 

Question 79: Write a C++ program to display the simple interest using a function.

Answer:

#include<iostream>
using namespace std;
float SimpleInt(float p, int n, float r)
{
return (p * n * r / 100);
}
int main()
{
float p, r, SI;
int n;
cout << "Enter values for p, n, r:";
cin >> p >> n >> r;
SI = SimpleInt(p, n, r);
cout << "Simple interest is " << SI;
}

Exam Tips:

a) Write the formula SI = PNR/100 as a comment or line before the program.
b) Make the function return the value and print it in main().

 

Question 80: Write a function definition to find the sum of natural numbers from 1 to N using recursion. (Hint: If the value of N is 5, the answer will be 1 + 2 + 3 + 4 + 5 = 15.)

Answer:

int sum(int n)
{
if (n == 0)
return 0;
else
return (n + sum(n - 1));
}
For n = 5: 5 + 4 + 3 + 2 + 1 + 0 = 15

Exam Tips:

a) The base case n == 0 returns 0 and stops the recursion.
b) Check your function with the given hint value (15 for N = 5).

 

Question 81: A program requires functions for adding 2 numbers, 3 numbers and 4 numbers. How can you provide a solution by writing a single function?

Answer:

It can be done by writing a function with default arguments.
int add(int n1, int n2, int n3 = 0, int n4 = 0)
{
return (n1 + n2 + n3 + n4);
}
This function can be called in the following ways:
1. add(5, 2); returns 5 + 2 = 7
2. add(5, 2, 7); returns 5 + 2 + 7 = 14
3. add(5, 2, 7, 10); returns 5 + 2 + 7 + 10 = 24

Exam Tips:

a) Give the default value 0 so that the missing numbers do not change the sum.
b) Show all three calls with their results.

 

Question 82: Explain the difference between the call by value method and the call by reference method with the help of examples.

Answer:

1. Call by value: A copy of the original value is passed to the function. Any change made by the function does not affect the original value.
Example:
#include<iostream>
using namespace std;
void swap(int x, int y)
{
int temp;
temp = x;
x = y;
y = temp;
}
int main()
{
int a, b;
cout << "Enter 2 nos";
cin >> a >> b;
cout << "The values before swap a = " << a << " and b = " << b;
swap(a, b);
cout << "\nThe values after swap a = " << a << " and b = " << b;
}
There is no change in the values.
2. Call by reference: The reference (address) of the original value is passed to the function. Any change made by the function affects the original value.
Example:
#include<iostream>
using namespace std;
void swap(int &x, int &y)
{
int temp;
temp = x;
x = y;
y = temp;
}
int main()
{
int a, b;
cout << "Enter 2 nos";
cin >> a >> b;
cout << "The values before swap a = " << a << " and b = " << b;
swap(a, b);
cout << "\nThe values after swap a = " << a << " and b = " << b;
}
The values of a and b are exchanged.

Exam Tips:

a) Write the definition of each method in one line before its example.
b) Mention the & symbol in the reference version.

 

Question 83: Explain recursive functions with the help of a suitable example.

Answer:

A function that calls itself is called a recursive function.
#include<iostream>
using namespace std;
void convert(int n)
{
if (n > 1)
convert(n/2);
cout << n % 2;
}
int main()
{
convert(7);
}
Here convert() is a recursive function because it calls itself. The output of the program is 111 (the binary form of 7).

Exam Tips:

a) Point out the base condition (here n > 1) that stops the recursion.
b) Write the output of your example.

 

Question 84: Name the built-in function used to check whether a character is alphanumeric or not.

Answer:

isalnum()
It is in the cctype header file. It returns a non-zero value if the character is an alphabet or a digit; otherwise it returns 0.

Exam Tips:

a) For a three-mark version, add the header file, the return value and an example such as isalnum('a').

 

Question 85: Briefly explain the three components in the structure of a C++ program.

Answer:

1. Preprocessor directives:
A C++ program starts with preprocessor directives, which begin with #. Examples are #include, #define and #undef. #include links the header files needed for the functions used. #define is used to define constants.
Example: #define x 100. Here x becomes 100 and cannot be changed in the program. No semicolon is needed.
2. Header files:
A header file is a stored file that helps us use some operators and functions. Some header files are iostream, iomanip, cstdio, cctype, cmath and cstring.
Syntax: #include<name of the header file>
Example: #include<iostream>
3. The main() function:
main() is the first function executed when the program runs, and the program ends within main(). Other functions are called from main().

Exam Tips:

a) Write each component as a heading with one or two lines of explanation and an example.

 

Question 86: Explain the difference between the call by value method and the call by reference method with the help of examples.

Answer:

1. Call by value: A copy of the original value is passed to the function. Any change made by the function does not affect the original value.
Example:
void change(int y)
{
y = 40;
}
int main()
{
int x = 0;
change(x);
cout << x;
}
Output: 0 (x is not changed)
2. Call by reference: The reference of the original value is passed to the function. Any change made by the function affects the original value.
Example:
void change(int &y)
{
y = 40;
}
int main()
{
int x = 0;
change(x);
cout << x;
}
Output: 40 (x is changed)

Exam Tips:

a) A short example like this is enough for three marks; show the output for each.
b) The & symbol in the parameter is the only difference between the two.

 

Five Mark Questions and Answers

Question 87: Write short notes on character functions and string functions.

Answer:

A. Character functions (header file cctype):
1. isalnum(): Checks whether a character is an alphabet or a digit. It returns a non-zero value if it is an alphabet or digit; otherwise it returns zero.
2. isalpha(): Checks whether a character is an alphabet. It returns a non-zero value if it is an alphabet; otherwise it returns zero.
3. isdigit(): Checks whether a character is a digit. It returns a non-zero value if it is a digit; otherwise it returns zero.
4. islower(): Checks whether a character is a lower case alphabet. It returns a non-zero value if it is; otherwise it returns zero.
5. isupper(): Checks whether a character is an upper case alphabet. It returns a non-zero value if it is; otherwise it returns zero.
6. tolower(): Converts an alphabet into lower case.
7. toupper(): Converts an alphabet into upper case.
B. String functions (header file cstring):
1. strcpy(): Copies one string into another.
2. strcat(): Joins (concatenates) the second string to the end of the first string.
3. strlen(): Finds the length of a string.
4. strcmp(): Compares two strings. It returns a negative value if the first string is less than the second, zero if both are equal, and a positive value if the first string is greater than the second.

Exam Tips:

a) Give the header file for each group; it is an easy extra point.
b) Write a one-line example for a few functions, such as strlen("Kerala") gives 6.
c) For five marks, cover at least four character functions and four string functions.

 

Question 88: Write functions to perform the following operations.
1. Square root
2. Power of 2 numbers
3. sin
4. cos

Answer:

#include<iostream>
#include<cmath>
using namespace std;
void sqroot()
{
int n;
cout << "Enter the number to find square root";
cin >> n;
cout << "The square root of " << n << " is " << sqrt(n);
}
void Power()
{
int m, n;
cout << "Enter a number and power";
cin >> m >> n;
cout << "The result of " << m << " power " << n << " is " << pow(m, n);
}
void sine()
{
float n;
cout << "Enter an angle in radians";
cin >> n;
cout << "sin(" << n << ") is " << sin(n);
}
void cosine()
{
float n;
cout << "Enter an angle in radians";
cin >> n;
cout << "cos(" << n << ") is " << cos(n);
}
int main()
{
int ch;
do
{
cout << "\n1. Square root\n2. Power of 2 nos\n3. sin\n4. cos\nEnter the choice (zero for exit)";
cin >> ch;
switch (ch)
{
case 1: sqroot(); break;
case 2: Power(); break;
case 3: sine(); break;
case 4: cosine(); break;
}
} while (ch != 0);
}

Exam Tips:

a) Include cmath for sqrt(), pow(), sin() and cos().
b) sin() and cos() take the angle in radians, not degrees; multiply degrees by 3.14159/180 to convert.
c) A menu with switch lets one program call all four functions.

 

Question 89: Write a C++ program to display the roots of a quadratic equation.

Answer:

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
float a, b, c, d, r1, r2;
cout << "Enter the coefficients a, b and c";
cin >> a >> b >> c;
d = b*b - 4*a*c;
if (d == 0)
{
cout << "The roots are real and equal";
r1 = r2 = -b / (2.0*a);
cout << "\nr1 = r2 = " << r1;
}
else if (d > 0)
{
cout << "The roots are real and unequal";
r1 = (-b + sqrt(d)) / (2.0*a);
r2 = (-b - sqrt(d)) / (2.0*a);
cout << "\nr1 = " << r1 << " and r2 = " << r2;
}
else
{
cout << "The roots are imaginary";
float real = -b / (2.0*a);
float imag = sqrt(-d) / (2.0*a);
cout << "\nr1 = " << real << " + " << imag << "i";
cout << "\nr2 = " << real << " - " << imag << "i";
}
}

Exam Tips:

a) Find the discriminant d = b² - 4ac first and check its three cases: d = 0, d > 0 and d < 0.
b) Use 2.0*a or float variables so that the division does not lose the decimal part.
c) For imaginary roots, the real part is -b/(2a) and the imaginary part is sqrt(-d)/(2a).

 

Question 90: Explain the 'call by value' and 'call by reference' methods of function calling with the help of a suitable example.

Answer:

There are two methods: call by value and call by reference.
1. Call by value: A copy of the original value is passed to the function. Any change made by the function does not affect the original value.
Example:
#include<iostream>
using namespace std;
void swap(int x, int y)
{
int temp;
temp = x;
x = y;
y = temp;
}
int main()
{
int a, b;
cout << "Enter 2 nos";
cin >> a >> b;
cout << "The values before swap a = " << a << " and b = " << b;
swap(a, b);
cout << "\nThe values after swap a = " << a << " and b = " << b;
}
There is no change in the values.
2. Call by reference: The reference (address) of the original value is passed to the function. Any change made by the function affects the original value.
Example:
#include<iostream>
using namespace std;
void swap(int &x, int &y)
{
int temp;
temp = x;
x = y;
y = temp;
}
int main()
{
int a, b;
cout << "Enter 2 nos";
cin >> a >> b;
cout << "The values before swap a = " << a << " and b = " << b;
swap(a, b);
cout << "\nThe values after swap a = " << a << " and b = " << b;
}
The values of a and b are exchanged.

Exam Tips:

a) Show a sample run, for example input 3 and 5: by value prints 3 and 5 again; by reference prints 5 and 3.
b) Mention that call by reference can be used to return more than one value.
c) Keep the two programs the same except for the & symbol.

 

Question 91: Define network topology. Explain any four network topologies in detail.

Answer:

Network topology: The physical or logical arrangement of computers in a network is called its topology. It is the geometrical arrangement of computers in a network. The major topologies are star, bus, ring, tree and mesh.
1. Star topology: All computers are connected to a central device (server, hub or switch). If computer A wants to send a message to computer B, A sends it to the central device, which then sends it to B. So all messages pass through the centre.
Advantages: Adding or removing computers is easy, and the failure of one computer does not affect the others.
Disadvantage: If the central device fails, the whole network fails.
2. Bus topology: All computers are connected to a single cable called the bus. When one computer transmits, all others listen, so it is called a broadcast bus. The signal travels in both directions, and each computer checks whether the message is for it.
Advantages: Adding or removing computers is easy, it needs less cable and the installation cost is low.
Disadvantage: Finding a fault is difficult because there is no central computer.
3. Ring topology: The computers are connected in the shape of a ring (a closed loop) with no central computer. A message carries the address of the destination computer and travels in one direction. Each node checks whether the message is for it; if not, it passes the message to the next node.
Advantage: It needs only a short cable length.
Disadvantages: If one node fails, at least a part of the network fails, and adding a node is difficult.
4. Hybrid topology: It is a combination of two or more topologies. Tree and mesh topologies can be considered hybrid topologies.
(a) Tree topology: It has the shape of an inverted tree, with a central node and branches as nodes. It is a variation of the bus topology, and data is sent in the same way as in a bus. If one node fails, the part of the network below it fails.
(b) Mesh topology: Each node is connected to more than one node, like a net. There are many paths between computers, so if one path fails, data can be sent through another path.

Exam Tips:

a) Draw a small diagram for each topology if time permits; diagrams help score in five-mark questions.
b) For each topology, write how computers are connected, one advantage and one disadvantage.
c) Mention that tree and mesh are often treated as hybrid topologies; this shows complete knowledge.

 

Kerala Board Solutions for Class 11 Computer Science Chapter 10 Functions

Accessing Chapter 10 Functions Solutions

Access structured Kerala Board textbook solutions for Chapter 10 Functions. Designed in alignment with the latest academic curriculum for Class 11 Computer Science, these answers cover all end-of-chapter exercises to support daily learning and homework completion.

Concept-Driven Answers for Class 11 Computer Science

Each solution includes detailed reasoning to foster genuine comprehension of Chapter 10 Functions concepts. Reviewing these step-by-step breakdowns allows learners to master both analytical and descriptive questions expected in school evaluations.

Maximizing Study Efficiency

Consistent practice with these solution guides cultivates faster problem-solving habits and clearer logical structuring. For a complete preparation experience, pair these textbook answers with our dedicated revision notes and sample papers for Class 11 Computer Science.

FAQs

Where can I find the latest Kerala Plus One Computer Science Chapter 10 Functions Questions and Answers for the 2026-27 session?

The complete and updated Kerala Plus One Computer Science Chapter 10 Functions Questions and Answers is available for free on StudiesToday.com. These solutions for Class 11 Computer Science are as per latest Kerala Board curriculum.

Are the Computer Science Kerala Board solutions for Class 11 updated for the new 50% competency-based exam pattern?

Yes, our experts have revised the Kerala Plus One Computer Science Chapter 10 Functions Questions and Answers as per 2026 exam pattern. All textbook exercises have been solved and have added explanation about how the Computer Science concepts are applied in case-study and assertion-reasoning questions.

How do these Class 11 Kerala Board solutions help in scoring 90% plus marks?

Toppers recommend using Kerala Board language because Kerala Board marking schemes are strictly based on textbook definitions. Our Kerala Plus One Computer Science Chapter 10 Functions Questions and Answers will help students to get full marks in the theory paper.

Do you offer Kerala Plus One Computer Science Chapter 10 Functions Questions and Answers in multiple languages like Hindi and English?

Yes, we provide bilingual support for Class 11 Computer Science. You can access Kerala Plus One Computer Science Chapter 10 Functions Questions and Answers in both English and Hindi medium.

Is it possible to download the Computer Science Kerala Board solutions for Class 11 as a PDF?

Yes, you can download the entire Kerala Plus One Computer Science Chapter 10 Functions Questions and Answers in printable PDF format for offline study on any device.