Samacheer Kalvi Class 11 Computer Science Solutions Chapter 11 Functions

Get the most accurate TN Board Solutions for Class 11 Computer Science Chapter 11 Functions here. Updated for the 2026-27 academic session, these solutions are based on the latest TN Board textbooks for Class 11 Computer Science. Our expert-created answers for Class 11 Computer Science are available for free download in PDF format.

Detailed Chapter 11 Functions TN Board Solutions for Class 11 Computer Science

For Class 11 students, solving TN Board textbook questions is the most effective way to build a strong conceptual foundation. Our Class 11 Computer Science solutions follow a detailed, step-by-step approach to ensure you understand the logic behind every answer. Practicing these Chapter 11 Functions solutions will improve your exam performance.

Class 11 Computer Science Chapter 11 Functions TN Board Solutions PDF

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

11th Computer Science Guide Functions Text Book Questions and Answers

Book Evaluation

Part I

Choose The Correct Answer

 

Question 1. Which of the following header file defines the standard I/O predefined functions ?
(a) stdio.h
(b) math.h
(c) string.h
(d) ctype.h
Answer: (a) stdio.h
In simple words: The `stdio.h` file helps your computer program to read things you type and show you information on the screen. It is fundamental for basic input/output operations.

๐ŸŽฏ Exam Tip: Remember `stdio.h` for basic input/output like `printf` and `scanf` in C, and `iostream` for C++ input/output like `cout` and `cin`.

 

Question 2. Which function is used to check whether a character is alphanumeric or not ?
(a) isalpha()
(b) isdigit()
(c) isalnum()
(d) islower()
Answer: (c) isalnum()
In simple words: The `isalnum()` function checks if a character is a letter or a number. This function is helpful when validating input, such as usernames.

๐ŸŽฏ Exam Tip: Functions starting with "is" usually check a condition (like `isdigit()` checks for a digit), while functions starting with "to" usually convert a character (like `tolower()` converts to lowercase).

 

Question 3. Which function begins the program execution ?
(a) isalpha()
(b) isdigit()
(c) main()
(d) islower()
Answer: (c) main()
In simple words: Every C++ program starts running from the `main()` function. This is the entry point that the operating system looks for.

๐ŸŽฏ Exam Tip: Always remember that `main()` is crucial; without it, a C++ program cannot compile or run, as it tells the computer where to begin execution.

 

Question 4. Which of the following function is with a return value and without any argument ?
(a) x=display(int/ int)
(b) x=display()
(c) y=display(float)
(d) display(int)
Answer: (b) x=display()
In simple words: `x=display()` means a function that gives back a result but doesn't need any input. The assignment to `x` indicates a return value.

๐ŸŽฏ Exam Tip: A function returning a value means its output can be stored in a variable (like `x`). No arguments mean the parentheses are empty when called.

 

Question 5. Which is return data type of the function prototype of add (int, int); ?
(a) int
(b) float
(c) char
(d) double
Answer: (a) int
In simple words: The `int` at the start tells you what kind of answer the `add` function will give back. This is the value's data type.

๐ŸŽฏ Exam Tip: The return type is always written before the function name in a function prototype, indicating the type of data the function will produce.

 

Question 6. Which of the following is the scope operator ?
(a) >
(b) &
(c) %
(d) ::
Answer: (d) ::
In simple words: The `::` symbol helps you point to the correct function or variable when there are many with the same name. It clarifies which scope to look in.

๐ŸŽฏ Exam Tip: The scope resolution operator `::` is very important in object-oriented programming to access class members or global variables when a local variable has the same name.

Part - II

Very Short Answers

 

Question 1. Define Functions.
Answer: Functions are small, separate blocks of code within a larger program. Each function is designed to do a specific job. Breaking a big program into smaller functions helps to make the program simpler and easier to manage, understand, and find mistakes in. Functions also allow you to reuse code, saving time and effort on repetitive tasks.
In simple words: Functions are like mini-programs inside a main program, each doing a specific task. They make big programs easier to handle and debug.

๐ŸŽฏ Exam Tip: When defining functions, focus on "modularity" (breaking into parts), "reusability" (using code again), and "simplification" (making code easier).

 

Question 2. Write about strlen() function.
Answer: The `strlen()` function is used to find the length of a string in C++. It takes a string as input, which must end with a null character (`\0`). The function then counts how many characters are in the string before it reaches this null character, and that count is the length it returns. It's important to remember that `strlen()` does not include the null character itself in the count, only the visible characters.
Example:
`char source[ ] = "Computer Science";`
`cout <<"\n Given String is "<Output:
`Given String is Computer Science its Length is 16`
In simple words: The `strlen()` function counts how many letters are in a word or sentence. It stops counting just before the special end-of-string mark `\0`.

๐ŸŽฏ Exam Tip: Remember that `strlen()` calculates the number of characters, excluding the null terminator (`\0`), which marks the end of a C-style string.

 

Question 3. What are the importance of void data type?
Answer: The `void` data type serves two main purposes in C++. First, when used as a function's return type, it tells the compiler that the function does not send back any value after it finishes its job. Second, `void` can be used to declare a "generic pointer," which is a pointer that can point to any type of data without specifying it in advance. This makes the pointer flexible for different uses, enabling dynamic memory allocation.
1. To indicate the function does not return a value.
2. To declare a generic pointer.
In simple words: The `void` type either means a function gives no answer, or it makes a pointer that can point to any type of data.

๐ŸŽฏ Exam Tip: The `void` keyword is vital for functions that only perform actions (like printing) and for flexible pointers that can adapt to different data types.

 

Question 4. What is Parameter and list its types?
Answer: Parameters, also known as arguments, are pieces of information or values that are sent from one part of a program (the calling function) to another part (the called function). They act as placeholders for the data a function needs to work with. This allows functions to be more versatile and operate on different inputs. There are two main types:
1. **Formal Parameters:** These are the variables listed inside the parentheses in a function's definition. They represent the type of data the function expects to receive.
2. **Actual Parameters:** These are the specific values, variables, or expressions that are sent to the function when it is called. These actual values are passed into the formal parameters.
In simple words: Parameters are information given to a function. Formal parameters are names in the function's plan, and actual parameters are the real values you send when you use the function.

๐ŸŽฏ Exam Tip: Distinguish between formal (defined in function header) and actual (passed during function call) parameters, as this understanding is fundamental to how functions process data.

 

Question 5. Write a note on Local Scope.
Answer: Local scope refers to the limited area within a program where a variable can be seen and used. It dictates where a variable is valid and can be used, and how long it exists in memory.
1. A local variable is created inside a specific block of code, which is typically marked by curly braces `{}`.
2. Its visibility is restricted only to that block; it cannot be accessed from outside.
3. A local variable is created upon entry into its block and is automatically removed from memory once the program exits that block. This helps in managing memory efficiently and preventing naming conflicts.
In simple words: A local variable only works inside the part of the code where it was made, usually between `{}`. It starts when that part of the code begins and disappears when it ends.

๐ŸŽฏ Exam Tip: Understanding local scope is key to preventing variable naming conflicts and ensuring that variables are only used where they are intended, leading to cleaner code.

Part - III

Short Answers

 

Question 1. What is Built-in functions?
Answer: Built-in functions are ready-made functions that are already provided as part of the programming language or its standard libraries. These functions are available for use by default, meaning programmers do not need to write them from scratch. They perform common tasks efficiently, saving time and ensuring code correctness. Examples include `strlen()` for string length or `sqrt()` for square root calculations.
In simple words: Built-in functions are like tools that are already made and ready to use in your computer program. You don't have to build them yourself.

๐ŸŽฏ Exam Tip: Built-in functions are a great resource for efficiency; knowing the common ones (like `sqrt`, `strlen`, `max`) can significantly speed up coding and reduce errors.

 

Question 2. What is the difference between isupper() and toupper() functions?
Answer: The `isupper()` and `toupper()` functions both deal with uppercase characters but serve different purposes:
* **`isupper()` Function:** This function checks if a given character is an uppercase letter (like 'A', 'B', 'C'). It returns a non-zero value (often `1`) if the character is uppercase, and `0` if it is not. Importantly, it doesn't change the character itself.
* **`toupper()` Function:** This function converts a given character into its uppercase equivalent. If the character is already uppercase, it remains unchanged. If it's a lowercase letter, it becomes uppercase. If it's not a letter, it typically stays the same. This function directly modifies the character's case.
In simple words: `isupper()` asks "Is this letter big?" and gives a yes or no answer. `toupper()` changes a letter to its big form if it isn't already.

๐ŸŽฏ Exam Tip: Remember the "is" vs. "to" pattern: "is" functions check a condition (e.g., `isdigit`), and "to" functions transform a character (e.g., `tolower`).

 

Question 3. Write about strcmp() function.
Answer: The `strcmp()` function in C++ is used to compare two strings character by character. It takes two strings as input and checks them in alphabetical (lexicographical) order based on their ASCII values. The function then returns one of three possible values:
* A **positive value** if the first string comes after the second string alphabetically (meaning its first differing character has a higher ASCII value).
* A **negative value** if the first string comes before the second string alphabetically (meaning its first differing character has a lower ASCII value).
* **Zero (`0`)** if both strings are exactly the same.
This function is very useful for sorting strings or checking if two pieces of text are identical, providing a quick way to compare textual data.
Example:
cpp
#include <string.h>
#include <iostream>
using namespace std;
int main()
{
char string1[] = "Computer";
char string2[] = "Science";
int result;
result = strcmp(string1,string2);
if(result==0)
{
cout<<"String1 : "<<string1<<" and String2 : "<<string2 <<" Are Equal";
}
else
{
cout<<"String1 :"<<string1<<" and String2 : "<<string2<<" Are Not Equal";
}
}

Output:
`String1 : Computer and String2 : Science Are Not Equal`
In simple words: The `strcmp()` function checks if two words are the same, or which one comes first in the dictionary. It gives a number to tell you the result.

๐ŸŽฏ Exam Tip: When using `strcmp()`, a return value of 0 is the *only* indication of equality. Any non-zero value means the strings are different, but the sign (positive/negative) tells you their relative order.

 

Question 4. Write short note on pow() function in C++.
Answer: The `pow()` function in C++ is used to calculate a number raised to a certain power. It takes two input values: a "base" number and an "exponent." The function then computes the base number multiplied by itself the number of times specified by the exponent. For example, `pow(5, 4)` would calculate 5 to the power of 4 (5 x 5 x 5 x 5). The result typically returns as a `double` data type, but if any input argument is a `long double`, the return type will also be a `long double` for higher precision. This function is defined in the `` header file, making it readily available for mathematical computations.
Example:
cpp
#include <iostream>
#include <math.h>
using namespace std;
int main ()
{
double base, exponent, result;
base = 5;
exponent = 4;
result = pow(base, exponent);
cout << "pow(" << base << "^" << exponent << ") = " << result;
return 0;
}

Output:
`pow(5^4) = 625`
In simple words: The `pow()` function helps you quickly find a number multiplied by itself many times, like 5 raised to the power of 4.

๐ŸŽฏ Exam Tip: Remember to include `` when using `pow()`. Always double-check the data types for both input and output to avoid unexpected precision issues, especially with large numbers.

 

Question 5. What are the information the prototype provides to the compiler?
Answer: A function prototype (also known as a function declaration) gives the compiler important information about a function before it is actually used. This information includes:
1. **Return Type:** What kind of value the function will send back after it finishes. For example, `long`.
2. **Function Name:** The specific name of the function, like `fact`.
3. **Parameters (Arguments):** The number and types of values the function expects to receive as input. For instance, it might expect an `int` as the first argument and a `double` as the second.
This allows the compiler to check if a function call is correct before the function's full definition is even seen, ensuring type-safety and proper usage.
In simple words: A function prototype tells the computer what kind of answer a function gives, what its name is, and what kind of information it needs to work.

๐ŸŽฏ Exam Tip: Think of a function prototype as a "forward declaration" that allows you to call a function before its full definition appears in the code. It ensures type-checking and proper linking during compilation.

 

Question 6. What is default arguments ? Give example.
Answer: Default arguments in C++ allow a function's parameters to have pre-set values. This means if you call the function without providing a specific value for such a parameter, the function will automatically use its default value. This feature makes functions more flexible, as you can call them with fewer arguments if the default values are suitable. When defining default arguments, they must be assigned from right to left in the parameter list, making the function calls more convenient.
Example:
`void defaultvalue(int n1=10, int n2=100);`
In simple words: Default arguments are like backup values for a function's inputs. If you don't give a value for an input, the function uses its default one.

๐ŸŽฏ Exam Tip: When declaring default arguments, always assign them from right to left in the parameter list. You cannot have a default argument followed by a non-default argument, as this would create ambiguity.

Part - IV

Explain in Detail

 

Question 1. Explain the Call by value method with a suitable example.
Answer: Call by value is a method of passing arguments to a function where a copy of the actual value of an argument is sent to the function. This means that the function receives its own separate copy of the data. Any changes or modifications made to this copied value inside the function will **not** affect the original (actual) variable in the calling part of the program. It's like giving someone a photocopy of a document โ€“ whatever they write on the photocopy doesn't change your original document. This method ensures that the original data remains safe and unchanged, which is crucial for data integrity.
Example:
cpp
#include <iostream>
using namespace std;
void display(int x)
{
int a_squared = x * x; // Using a_squared to differentiate from main's 'a'
cout<<"\n\nThe Value inside display function (a * a):"<< a_squared;
}
int main()
{
int a;
cout<<"\nExample : Function call by value:";
cout<<"\n\nEnter the Value for A: ";
cin>>a;
display(a);
cout<<"\n\nThe Value inside main function: "<<a;
return (0);
}

Output:
`Example: Function call by value`
`Enter the Value for A: 5`
`The Value inside display function (a * a): 25`
`The Value inside main function: 5`
In simple words: In "call by value," a function gets a copy of your data. If the function changes its copy, your original data stays exactly the same.

๐ŸŽฏ Exam Tip: The key characteristic of call by value is that the original variable is protected from modification, as the function operates on a separate copy. This makes it a safe way to pass data.

 

Question 2. What is Recursion? Write a program to find GCD using recursion.
Answer: Recursion is a programming technique where a function calls itself to solve a problem. A recursive function solves a problem by breaking it down into smaller, similar sub-problems, and then calls itself to solve those sub-problems. This process continues until a simple base case is reached, which can be solved directly without further recursion. This elegant method is particularly useful for problems that naturally exhibit a recursive structure, such as tree traversals or mathematical sequences like factorials.
Program to find GCD (Greatest Common Divisor) using recursion:
cpp
#include <iostream>
using namespace std;

// Function to find GCD using recursion (Euclidean algorithm)
int gcd(int n1, int n2)
{
if (n2 != 0)
return gcd(n2, n1 % n2); // Recursive call to find GCD
else
{
return n1; // Base case: if n2 is 0, n1 is the GCD
}
}

int main()
{
int num1, num2;
cout << "Enter two positive integers: ";
cin >> num1 >> num2;
cout << "Greatest Common Divisor (GCD) of " << num1;
cout << " & " << num2 << " is: " << gcd(num1, num2);
return 0;
}

Output:
`Enter two positive integers: 350 100`
`Greatest Common Divisor (GCD) of 350 & 100 is: 50`
In simple words: Recursion is when a function solves a big problem by calling itself to solve smaller parts of the same problem, until it reaches a very simple part it can solve directly.

๐ŸŽฏ Exam Tip: Every recursive function must have a "base case" that stops the recursion. Without it, the function would call itself endlessly, leading to a stack overflow error.

 

Question 3. What are the different forms of function return? Explain with example.
Answer: Functions can be designed in several ways regarding whether they return a value and whether they accept parameters. Here are two common forms of user-defined function declarations, focusing on their return behavior:
1. **Function Without Return Value and Without Parameters:**
* This type of function performs a task but does not send back any result to the calling part of the program. It also doesn't need any input values to perform its task. The return type is typically `void`.
* *Example:* A function that simply prints a message to the screen.
* *Code Example:*
cpp
#include <iostream>
using namespace std;

void display() // No return type (void), no parameters
{
cout << "Function without parameter and return value";
}

int main()
{
display(); // Calls the function
return 0;
}

* *Output:*
`Function without parameter and return value`
2. **Function With Return Value and Without Parameters:**
* This function performs a task and calculates a result, which it then sends back to the part of the program that called it. However, it does not need any input parameters to do its work. The return type will be the data type of the value it sends back (e.g., `int`, `float`).
* *Example:* A function that calculates a sum from user input and returns the total.
* *Code Example:*
cpp
#include <iostream>
using namespace std;

int display() // Returns an integer, no parameters
{
int a, b, s;
cout << "Enter 2 numbers: ";
cin >> a >> b;
s = a + b;
return s; // Returns the calculated sum
}

int main()
{
int m = display(); // Calls function and stores returned value
cout << "\nThe Sum=" << m;
return 0;
}

* *Output:*
`Enter 2 numbers: 10 30`
`The Sum=40`
In simple words: Functions can be like little helpers. Some don't give you anything back and don't need instructions. Others do something and give you an answer back, but still don't need any instructions to start.

๐ŸŽฏ Exam Tip: Carefully define the return type and parameters for each function. If a function performs a task but doesn't need to pass information back, `void` is the correct return type.

 

Question 4. Explain scope of variable with an example.
Answer: The scope of a variable defines the region of a program where that variable can be accessed or seen. It dictates where a variable is valid and can be used, and how long it exists in memory. Understanding scope is vital for preventing naming conflicts and for managing memory effectively. C++ defines several types of scopes:
1. **Local Scope:** A variable with local scope is declared inside a specific block of code, typically enclosed by curly braces (`{}`). It is only accessible within that block and ceases to exist once the program execution leaves that block.
2. **Function Scope:** Variables declared within a function (usually parameters) are accessible throughout that function. Their lifetime is tied to the function's execution.
3. **File Scope (Global Scope):** Variables declared outside of any function or class have file scope. They are accessible from any part of the file after their declaration, lasting for the entire program execution.
4. **Class Scope:** Variables declared within a class are accessible to all member functions of that class. They define the properties of objects created from that class.
*Example (Local Scope):*
cpp
int main() {
int local_var = 10; // local_var has local scope
if (true) {
int another_local_var = 20; // another_local_var has local scope within this if block
cout << another_local_var; // This is OK
}
// cout << another_local_var; // This would cause an error: another_local_var is out of scope
cout << local_var; // This is OK
return 0;
}

In simple words: A variable's "scope" is like its personal boundary; it's the part of the program where that variable can be used. There are different types, like a "local" variable that only works inside a small code block.

๐ŸŽฏ Exam Tip: Always consider a variable's scope when writing code. Using local variables limits their visibility and reduces potential errors, making your program more organized and easier to maintain.

Part - IV

Question 4. Explain scope of variable with an example.
Answer: Variable scope defines where a variable can be accessed in a program. In C++, there are four main types of scopes:
1. Local Scope: A local variable is defined inside a specific block of code, which starts and ends with curly braces {}. This variable can only be used within that block. It is created when the block is entered and removed when the block is exited.
Example:
int main()
{
  int a, b; // These are local variables
}

2. Function Scope: A variable declared within a function can be accessed throughout that function and any smaller blocks inside it. The variable exists as long as the function is running.
Example:
int sum(int x, int y); // x and y have function scope here
3. File Scope: A variable declared outside all blocks and functions, including `main()`, has file scope. This means it can be accessed from any part of the program file it is declared in. These are also known as global variables and exist for the entire duration of the program.
Example:
#include <iostream>
using namespace std;
int x, y; // x and y are global variables
void main()
{
  // Code here
}

4. Class Scope: Data members declared within a class have class scope. They can be accessed by all the functions that belong to that class. Classes help group data of different types together, and these data members define the characteristics of a class.
Example:
class Example {
  int x, y; // x and y can be accessed by print() and void()
  void print();
  void total();
};

CodeDescription
class student {
  private:
    int mark1, mark2, total;
}
The student class contains mark1, mark2, and total as data variables. Their scope is limited to the student class only.

In simple words: Scope tells you where a variable can be used in your code. It's like a boundary for variables. There are different types, like local (inside a small block), function (inside a whole function), file (everywhere in the file), and class (inside a class). Each scope type has its own rules for when a variable can be seen and used.

๐ŸŽฏ Exam Tip: Always remember that variables declared locally have a shorter lifespan and can only be accessed within their specific block, which helps prevent accidental changes from other parts of the program.

 

Question 5. Write a program to accept any integer number and reverse it.
Answer: Here is a C++ program that takes an integer number and then prints its reverse. It uses a loop to extract digits and rebuild the number in reverse.
PROGRAM:
using namespace std;
#include <iostream>
int reverse(int num)
{
  int r=0, d;
  while(num>0)
  {
    d = num % 10; // Get the last digit
    r = r * 10 + d; // Add it to the reversed number
    num = num / 10; // Remove the last digit from the original number
  }
  return r;
}
int main()
{
  int x;
  cout << "\nEnter a number";
  cin >> x;
  cout << "\nReverse of the number is " << reverse(x);
  return 0;
}

Output example when 123 is entered:
Enter a number: 123
Reverse of the number is 321
In simple words: This program takes a whole number, then flips its digits around. For example, if you give it 123, it will print 321. It does this by taking the last digit repeatedly and building a new number from those digits in reverse order.

๐ŸŽฏ Exam Tip: For programs involving number manipulation, clearly explain the logic of how each digit is extracted and processed in the loop to show your understanding.

 

11th Computer Science Guide Functions Additional Questions and Answers

Choose The Correct Answer 1 Mark

 

Question 1. .................. is the name of the function.
(a) Predefined
(b) Built-in
(c) Library
(d) All of the options
Answer: (d) All of the options
In simple words: All the given optionsโ€”Predefined, Built-in, and Libraryโ€”refer to types of functions that are already created and available for use.

๐ŸŽฏ Exam Tip: Understand that "Predefined," "Built-in," and "Library functions" often refer to the same concept: functions that come ready-to-use with the programming language.

 

Question 2. .................. reduce the size and complexity of a program, makes it easier to understand, test, and check for errors.
(a) Arrays
(b) Functions
(c) Structures
(d) Unions
Answer: (b) Functions
In simple words: Functions break down a big program into smaller, easier-to-manage pieces, which makes the code simpler, less complex, and easier to fix.

๐ŸŽฏ Exam Tip: Focus on the benefits of modular programming, especially how functions enhance code organization and problem-solving efficiency.

 

Question 3. The strcpy() function takes two arguments of ..................
(a) target and source
(b) upper and lower
(c) base and exponent
(d) none of these
Answer: (a) target and source
In simple words: The strcpy() function copies characters from a 'source' location to a 'target' location.

๐ŸŽฏ Exam Tip: Remember that in string manipulation functions like strcpy(), `target` is where data goes, and `source` is where data comes from.

 

Question 4. Functions which are available in the C++ language standard library is known as .................. functions.
(a) Built-in
(b) User-defined
(c) Either A or B
(d) None of these
Answer: (a) Built-in
In simple words: Functions that come already made and are part of the C++ standard library are called built-in functions.

๐ŸŽฏ Exam Tip: Distinguish between "built-in" (pre-existing) and "user-defined" (created by the programmer) functions to answer such questions correctly.

 

Question 5. The pow() function takes the two arguments of ..................
(a) target and source
(b) upper and lower
(c) base and exponent
(d) source and exponent
Answer: (c) base and exponent
In simple words: The pow() function needs two numbers: one is the base number, and the other tells you what power to raise it to.

๐ŸŽฏ Exam Tip: For mathematical functions, remember the common terms for their arguments, like base and exponent for power calculations, or numerator and denominator for fractions.

 

Question 6. Why functions are needed?
(a) Divide and conquer the purpose
(b) Reusability of code
(c) Reduce the complexity of a program
(d) All of the options
Answer: (d) All of the options
In simple words: Functions are important because they help break down big problems, let you reuse code, and make programs less complicated and easier to manage.

๐ŸŽฏ Exam Tip: When asked about the benefits of functions, remember key terms like modularity, reusability, and reduced complexity; often, all listed benefits are correct.

 

Question 7. The C++ program always has a main() function to .................. begin the program execution.
(a) 1
(b) 2
(c) 3
(d) null
Answer: (a) 1
In simple words: Every C++ program must have exactly one main() function, which is the starting point for the program to run.

๐ŸŽฏ Exam Tip: It is fundamental to C++ programming that `main()` is the single entry point for execution; this is a core concept.

 

Question 8. Ready-to-use subprograms are called ..................
(a) Pre-defined functions
(b) Built-in functions
(c) Either A or B
(d) None of these
Answer: (c) Either A or B
In simple words: Small programs that are already prepared for you to use are known as either pre-defined functions or built-in functions.

๐ŸŽฏ Exam Tip: Remember that "pre-defined" and "built-in" are often used interchangeably to describe functions that are part of the standard library.

 

Question 9. In C++ the arguments can be passed to a function in .................. ways.
(a) 2
(b) 1
(c) 3
(d) 7
Answer: (a) 2
In simple words: In C++, you can send information (arguments) to a function in two main ways: by value or by reference.

๐ŸŽฏ Exam Tip: Be ready to explain "call by value" and "call by reference" if this question is expanded into a descriptive one.

 

Question 10. A header file can be identified by their file extension ..................
(a) .head
(b) .h
(c) .hf
(d) None of these
Answer: (b) .h
In simple words: Header files in C++ usually have the .h ending in their name.

๐ŸŽฏ Exam Tip: Recognizing file extensions like `.h` for headers is a basic but important detail for C++ programming.

 

Question 11. .................. is a header file contains pre-defined standard input/output functions.
(a) conio.h
(b) istream.h
(c) iostream.h
(d) stdio.h
Answer: (d) stdio.h
In simple words: The stdio.h header file has many ready-made functions for things like reading input and printing output.

๐ŸŽฏ Exam Tip: stdio.h is crucial for basic input/output operations in C, and often used in C++ for compatibility, while iostream is the C++-native header.

 

Question 12. stdio.h header file defines the standard I/O predefined function ..................
(a) getchar()
(b) putchar()
(c) getsQ and puts()
(d) All of the options
Answer: (d) All of the options
In simple words: The stdio.h header file includes all of these common functions for input and output, such as getchar(), putchar(), gets(), and puts().

๐ŸŽฏ Exam Tip: Recognize that `stdio.h` provides a suite of functions for standard I/O, not just one, covering character and string operations.

 

Question 13. The predefined function .................. is used to get a single character from the keyboard.
(a) getchar()
(b) putchar()
(c) gets() and puts()
(d) puts()
Answer: (a) getchar()
In simple words: The getchar() function helps your program read just one letter or symbol that you type on the keyboard.

๐ŸŽฏ Exam Tip: Remember that `getchar()` is specifically for single characters, `gets()` for strings, and their `put-` counterparts are for output.

 

Question 14. The predefined function .................. is used to display a single character.
(a) getchar()
(b) putchar()
(c) gets()
(d) puts()
Answer: (b) putchar()
In simple words: To show just one letter or symbol on the screen, you use the putchar() function.

๐ŸŽฏ Exam Tip: Pair `getchar()` for input with `putchar()` for output when dealing with single characters.

 

Question 15. Function .................. reads a string from standard input and stores it into the string pointed by the variable.
(a) getchar()
(b) putchar()
(c) gets()
(d) puts()
Answer: (c) gets()
In simple words: The gets() function reads a whole line of text from your keyboard and saves it into a variable.

๐ŸŽฏ Exam Tip: Be aware that `gets()` is generally unsafe because it doesn't check buffer size, making it prone to buffer overflow vulnerabilities.

 

Question 16. Function .................. prints the string read by gets() function in a newline.
(a) getchar()
(b) putchar()
(c) gets()
(d) puts()
Answer: (d) puts()
In simple words: After gets() reads a line of text, the puts() function is used to print that text onto the screen, and it automatically moves to the next line.

๐ŸŽฏ Exam Tip: `puts()` automatically adds a newline character at the end of the string it prints, unlike `cout` which requires `\n` or `endl`.

 

Question 17. .................. header file defines various operations on characters.
(a) conio.h
(b) ctype.h
(c) iostream.h
(d) stdio.h
Answer: (b) ctype.h
In simple words: The ctype.h file contains special functions that help you check or change characters, like seeing if a character is a letter or making it uppercase.

๐ŸŽฏ Exam Tip: Remember `ctype.h` for character-related functions such as `isalpha()`, `isdigit()`, `toupper()`, and `islower()`, as they are frequently tested.

 

Question 18. .................. function is used to check whether a character is alphanumeric or not.
(a) isalnum()
(b) isalpha()
(c) isdigit()
(d) None of these
Answer: (a) isalnum()
In simple words: The isalnum() function checks if a character is either a letter (alphabet) or a number (digit).

๐ŸŽฏ Exam Tip: Differentiate `isalnum()` (checks for letters AND numbers) from `isalpha()` (checks for letters only) and `isdigit()` (checks for numbers only).

 

Question 19. .................. function returns a non-zero value if the given character is a digit or a letter, else it returns 0.
(a) isalnum()
(b) isaipha()
(c) isdigit()
(d) None of these
Answer: (a) isalnum()
In simple words: The isalnum() function gives back a number greater than zero if the character is a letter or a digit; otherwise, it returns zero.

๐ŸŽฏ Exam Tip: A non-zero return value generally indicates "true" or success in C/C++ character functions, while zero indicates "false" or failure.

 

Question 20. The .................. function is used to check whether the given character is an alphabet or not.
(a) isalnum()
(b) isalpha()
(c) isdigit()
(d) None of these
Answer: (b) isalpha()
In simple words: To find out if a character is a letter of the alphabet, you use the isalpha() function.

๐ŸŽฏ Exam Tip: Remember `isalpha()` specifically for alphabetic characters; it will return false for digits or symbols.

 

Question 21. .................. function will return 1 if the given character is an alphabet, and 0 otherwise 0.
(a) isalnum()
(b) isalpha()
(c) isdigit()
(d) None of these
Answer: (b) isalpha()
In simple words: The isalpha() function returns a 1 if the character you give it is a letter, and a 0 if it's anything else.

๐ŸŽฏ Exam Tip: Be precise about return values: 1 for true (alphabet), 0 for false (not an alphabet).

 

Question 22. .................. function is used to check whether a given character is a digit or not.
(a) isalnum()
(b) isalpha()
(c) isdigit()
(d) None of these
Answer: (c) isdigit()
In simple words: To see if a character is a number from 0 to 9, you use the isdigit() function.

๐ŸŽฏ Exam Tip: `isdigit()` is specifically for numeric characters, useful for validating inputs that should only contain numbers.

 

Question 23. .................. function will return 1 if the given character is a digit, and 0 otherwise.
(a) isalnum()
(b) isalpha()
(c) isdigit()
(d) None of these
Answer: (c) isdigit()
In simple words: The isdigit() function will give back 1 if the character is a digit, and 0 if it is not.

๐ŸŽฏ Exam Tip: Pay attention to the exact return values (1 for true, 0 for false) for character-checking functions.

 

Question 24. .................. function is used to check whether a character is in lower case (small letter) or not.
(a) islower()
(b) tolower()
(c) Both A and B
(d) None of these
Answer: (a) islower()
In simple words: The islower() function checks if a letter is a small letter (lowercase) or not.

๐ŸŽฏ Exam Tip: Distinguish between functions that `is-` (check a condition) and `to-` (convert a character).

 

Question 25. .................. functions will return a non-zero value if the given character is a lower case alphabet, and 0 otherwise.
(a) islower()
(b) tolower()
(c) toupper()
(d) isupper()
Answer: (a) islower()
In simple words: The islower() function gives a non-zero number if a character is a small letter; otherwise, it returns zero.

๐ŸŽฏ Exam Tip: A non-zero value indicates that the character satisfies the lowercase condition.

 

Question 26. .................. function is used to check whether the given character is uppercase.
(a) islower()
(b) tolower()
(c) toupper()
(d) isupper()
Answer: (d) isupper()
In simple words: To check if a character is a capital letter (uppercase), you use the isupper() function.

๐ŸŽฏ Exam Tip: Pair `islower()` with `isupper()` as their roles are opposite: one checks for lowercase, the other for uppercase.

 

Question 27. .................. function will return 1 if the given character is an uppercase alphabet otherwise 0.
(a) islower()
(b) tolower()
(c) toupper()
(d) isupper()
Answer: (d) isupper()
In simple words: The isupper() function returns 1 if the character is a capital letter, and 0 if it is not.

๐ŸŽฏ Exam Tip: Similar to other `is-` functions, `isupper()` uses 1 and 0 to signal true or false conditions.

 

Question 28. .................. function is used to convert the given character into its uppercase.
(a) islower()
(b) tolower()
(c) toupper()
(d) isupper()
Answer: (c) toupper()
In simple words: The toupper() function changes a small letter into a capital letter.

๐ŸŽฏ Exam Tip: Use `toupper()` for conversion and `isupper()` for checking the case of a character.

 

Question 29. .................. function will return the upper case equivalent of the given character.
(a) islower()
(b) tolower()
(c) toupper()
(d) isupper()
Answer: (c) toupper()
In simple words: The toupper() function takes a character and gives back its capital letter version.

๐ŸŽฏ Exam Tip: Note that `toupper()` converts the character to uppercase and returns the new character; it doesn't change the original variable directly unless assigned back.

 

Question 30. .................. function is used to convert the given character into its lowercase.
(a) islower()
(b) tolower()
(c) toupper()
(d) isupper()
Answer: (b) tolower()
In simple words: The tolower() function changes a big letter into a small letter.

๐ŸŽฏ Exam Tip: `tolower()` is the counterpart to `toupper()`, performing conversion from uppercase to lowercase.

 

Question 31. .................. function copies the character string pointed by the source to the memory location pointed by the target.
(a) strcpy()
(b) strcat()
(c) strcmp()
(d) strlen()
Answer: (a) strcpy()
In simple words: The strcpy() function takes a string from one place (source) and makes an exact copy of it in another place (target).

๐ŸŽฏ Exam Tip: Remember `strcpy()` for copying strings, and be aware of potential buffer overflows if the target buffer is too small for the source string.

 

Question 32. The .................. function takes a null-terminated byte string source as its argument and returns its length.
(a) strcpy()
(b) strcat()
(c) strcmp()
(d) strlen()
Answer: (d) strlen()
In simple words: The strlen() function counts how many characters are in a text string, stopping before the special null character at the end.

๐ŸŽฏ Exam Tip: `strlen()` calculates the length of a C-style string by counting characters until it finds the null terminator `\0`, which is not included in the count.

 

Question 33. The length of the string does not include the .................. character.
(a) Null(\0)
(b) Blank space
(c) White space
(d) None of these
Answer: (a) Null(\0)
In simple words: When you measure the length of a string, you don't count the special 'null' character that marks its end.

๐ŸŽฏ Exam Tip: Always remember that the null terminator `\0` is essential for C-style strings but is never counted in their reported length.

 

Question 34. function compares the contents of string1 and string2 lexicographically.
(a) strcpy()
(b) strcat()
(c) strcmp()
(d) strlen()
Answer: (c) strcmp()
In simple words: The \( \text{strcmp}() \) function looks at two strings letter by letter to see which one comes first in alphabetical order. It helps you compare them like words in a dictionary.

๐ŸŽฏ Exam Tip: Remember that \( \text{strcmp}() \) returns 0 if strings are equal, a positive value if the first string is greater, and a negative value if the first string is smaller.

 

Question 35. The Strcmp() function returns a value if the first differing character in string1 is greater than the corresponding character in string2.
(a) Positive
(b) Negative
(c) Zero
(d) None of these
Answer: (a) Positive
In simple words: When \( \text{strcmp}() \) compares two strings and finds a letter in the first string that has a bigger ASCII value than the letter in the same spot in the second string, it gives back a positive number. This means the first string is "larger" alphabetically.

๐ŸŽฏ Exam Tip: Understanding ASCII values is crucial for grasping how string comparison functions like \( \text{strcmp}() \) work internally.

 

Question 36. The Strcmp() function returns a value if the first differing character in stringl is less than the corresponding character in string2.
(a) Positive
(b) Negative
(c) Zero
(d) None of these
Answer: (b) Negative
In simple words: If \( \text{strcmp}() \) compares two strings and the first difference it finds is a character in the first string that is "smaller" (has a lower ASCII value) than the character in the same position in the second string, it will return a negative number. This tells you the first string comes before the second one in alphabetical order.

๐ŸŽฏ Exam Tip: Memorize the three possible return values (positive, negative, zero) for \( \text{strcmp}() \) and what each signifies for string ordering.

 

Question 37. function appends copy of the character string pointed by the source to the end of string pointed by the target.
(a) strcpy()
(b) strcat()
(c) strcmp()
(d) strlen()
Answer: (b) strcat()
In simple words: The \( \text{strcat}() \) function is used to join two strings together. It takes the second string and adds it right at the end of the first string.

๐ŸŽฏ Exam Tip: Always ensure the destination string (target) has enough allocated memory to hold the combined length of both strings to prevent buffer overflow.

 

Question 38. The function is used to convert the given string into Uppercase letters.
(a) strupr()
(b) toupper()
(c) Both A and B
(d) None of these
Answer: (a) strupr()
In simple words: The \( \text{strupr}() \) function changes all the small letters in a string to capital letters. For example, "hello" would become "HELLO".

๐ŸŽฏ Exam Tip: Be aware that \( \text{strupr}() \) is not part of the standard C++ library but is commonly found in some compilers like Borland C++ and GCC (via `` on Windows or `` with `_strupr` on Linux).

 

Question 39. The function is used to convert the given string into Lowercase letters.
(a) tolower()
(b) strlwr()
(c) Both A and B
(d) None of these
Answer: (b) strlwr()
In simple words: The \( \text{strlwr}() \) function changes all the capital letters in a string to small letters. For example, "HELLO" would become "hello".

๐ŸŽฏ Exam Tip: Similar to \( \text{strupr}() \), \( \text{strlwr}() \) is also not a standard C++ function and might require specific compiler extensions or platform-specific headers.

 

Question 40. The cos() function takes a single argument in ....................
(a) Radians
(b) Degree
(c) Either A or B
(d) None of these
Answer: (a) Radians
In simple words: The \( \text{cos}() \) function, which calculates the cosine in math, needs its input number to be in radians, not degrees. Radians are a different way to measure angles.

๐ŸŽฏ Exam Tip: Always convert angles from degrees to radians (degrees * \( \pi \) / 180) before using trigonometric functions like \( \text{cos}() \), \( \text{sin}() \), or \( \text{tan}() \) in C++ to get the correct results.

 

Question 41. The cos() function returns the value in the range of ....................
(a) [0, 1]
(b) [-1, 1]
(c) [1,-1]
(d) None of these
Answer: (b) [-1, 1]
In simple words: No matter what angle you give to the \( \text{cos}() \) function, the answer it gives will always be a number between -1 and 1, including -1 and 1 themselves.

๐ŸŽฏ Exam Tip: Both \( \text{sin}() \) and \( \text{cos}() \) functions produce values within the inclusive range of -1 to 1; this property is fundamental to trigonometry.

 

Question 42. The cos() function returns the value in ....................
(a) double
(b) float
(c) long double
(d) Either A or B or C
Answer: (d) Either A or B or C
In simple words: The \( \text{cos}() \) function can give back its answer in a few different types of numbers, like \( \text{double} \), \( \text{float} \), or \( \text{long double} \). The type it chooses depends on the type of number you give it as an input.

๐ŸŽฏ Exam Tip: In C++, standard math functions often have overloaded versions to handle various floating-point types (`float`, `double`, `long double`), returning a value of the corresponding type.

 

Question 43. The sqrt() function takes a .................... argument.
(a) single non-negative
(b) single negative
(c) double non-negative
(d) double negative
Answer: (a) single non-negative
In simple words: The \( \text{sqrt}() \) function calculates the square root of a number. It can only take one number as input, and that number must be zero or a positive number. You cannot find the square root of a negative number in real math.

๐ŸŽฏ Exam Tip: Passing a negative argument to \( \text{sqrt}() \) will result in a "domain error" because the square root of a negative number is not defined in the real number system.

 

Question 44. If a negative value is passed as an argument to sqrt() function, a .................... occurs,
(a) Data type mismatch
(b) Domain error
(c) Prototype mismatch
(d) None of these
Answer: (b) Domain error
In simple words: If you try to ask the \( \text{sqrt}() \) function to find the square root of a negative number, it will cause a "domain error". This means the input number is outside the allowed range for this mathematical operation.

๐ŸŽฏ Exam Tip: A domain error indicates that the input to a mathematical function is outside the acceptable mathematical range for that function.

 

Question 45. The function returns, the value in the range of [-1,1].
(a) cos()
(b) sin()
(c) Both A and B
(d) None of these
Answer: (c) Both A and B
In simple words: Both the \( \text{cos}() \) and \( \text{sin}() \) math functions always give answers that are between -1 and 1. They never go above 1 or below -1.

๐ŸŽฏ Exam Tip: Remember that trigonometric functions like sine and cosine are bounded because they represent ratios within a unit circle.

 

Question 46. The function returns base raised to the power of the exponent.
(a) exponent()
(b) power()
(c) pow()
(d) None of these
Answer: (c) pow()
In simple words: The \( \text{pow}() \) function in programming is used to find the result when a number (the base) is multiplied by itself a certain number of times (the exponent). For example, \( \text{pow}(2, 3) \) would be 2 multiplied by itself 3 times, which is 8.

๐ŸŽฏ Exam Tip: The \( \text{pow}() \) function is part of the `` or `` header and is essential for exponential calculations.

 

Question 47. If any argument passed to pow() is long double, the return type is promoted to ....................
(a) long double
(b) int
(c) double
(d) char
Answer: (a) long double
In simple words: When you use the \( \text{pow}() \) function and one of the numbers you give it is a \( \text{long double} \), which is a very precise type of number, the answer it gives back will also be a \( \text{long double} \). This keeps the calculation as accurate as possible.

๐ŸŽฏ Exam Tip: C++ promotes return types to match the highest precision argument to avoid loss of data and maintain accuracy in calculations.

 

Question 48. The pow() function takes .................... argument.
(a) base
(b) exponent
(c) Both A and B
(d) None of these
Answer: (c) Both A and B
In simple words: To use the \( \text{pow}() \) function, you need to tell it two things: the "base" number that will be multiplied, and the "exponent" number that tells how many times to multiply it. Both these numbers are needed as arguments.

๐ŸŽฏ Exam Tip: Always provide both the base and exponent arguments to the \( \text{pow}() \) function in the correct order: \( \text{pow(base, exponent)} \).

 

Question 49. The function in C++ seeds the pseudo-random number generator used by the rand() function.
(a) srand()
(b) sran()
(c) rands()
(d) None of these
Answer: (a) srand()
In simple words: The \( \text{srand}() \) function helps to start the process of creating random-like numbers. It takes a starting number, called a "seed," which ensures that the sequence of "random" numbers changes each time you run the program. This makes the numbers appear more random.

๐ŸŽฏ Exam Tip: To get different random numbers each time your program runs, typically seed \( \text{srand}() \) with the current time using \( \text{time(0)} \).

 

Question 50. The srand() function is defined in .................... header file.
(a)
(b)
(c) or
(d) None of these
Answer: (b)
In simple words: The \( \text{srand}() \) function, which is used to set the starting point for random numbers, can be found in a special file called ``. You need to include this file in your program to use \( \text{srand}() \).

๐ŸŽฏ Exam Tip: Always remember to include `` (or `` for C style) when working with pseudo-random number generation functions like \( \text{rand}() \) and \( \text{srand}() \).

 

Question 51. C++ program can contain .................... main"() function.
(a) Only one
(b) No
(c) More than one
(d) None of these
Answer: (a) Only one
In simple words: Every C++ program must have exactly one special function called \( \text{main}() \). This is where the program always starts running.

๐ŸŽฏ Exam Tip: The \( \text{main}() \) function is the entry point for every C++ program; having more than one will cause a compilation error.

 

Question 52. In C++, function begins the program execution.
(a) void
(b) main()
(c) User-defined
(d) Built-in
Answer: (b) main()
In simple words: In any C++ program, the computer always begins by running the instructions inside the \( \text{main}() \) function. It's like the program's starting line.

๐ŸŽฏ Exam Tip: Remember that \( \text{main}() \) is a special function; its presence and proper definition are crucial for a C++ program to be executable.

 

Question 53. data type is used to indicate the function does not return a value.
(a) int
(b) double
(c) void
(d) unsigned
Answer: (c) void
In simple words: When a function is set to be of \( \text{void} \) type, it means that after it finishes its job, it won't give back any specific value. It just performs its tasks.

๐ŸŽฏ Exam Tip: Functions declared with `void` as their return type should not use a `return` statement with a value, only `return;` or implicitly return at the end.

 

Question 54. data type is used to declare a generic pointer.
(a) int
(b) double
(c) void
(d) unsigned
Answer: (c) void
In simple words: A \( \text{void} \) pointer is like a general-purpose pointer that can point to any type of data without knowing what that data is. It's used when you want a pointer that can be flexible.

๐ŸŽฏ Exam Tip: While `void*` pointers can point to any data type, they must be explicitly cast to a specific data type before dereferencing them.

 

Question 55. The user-defined function should be called explicitly using its ....................
(a) Name
(b) Arguments to be passed
(c) Both A and B
(d) None of these
Answer: (c) Both A and B
In simple words: To make a function that you created yourself run, you need to use its exact name and also give it any information or "arguments" it needs to do its job.

๐ŸŽฏ Exam Tip: When calling a user-defined function, ensure the name and the number/type of arguments exactly match its definition or prototype to avoid compilation errors.

 

Question 56. Which of the following calling the function have a return value and with arguments?
(a) display();
(b) display(x,y);
(c) x = display();
(d) x = display(x,y);
Answer: (d) x = display(x,y);
In simple words: This option shows a function call that does two things: it sends specific values (x and y) to the function as input, and it also expects a result back from the function, which is then stored in the variable `x`.

๐ŸŽฏ Exam Tip: A function call that assigns its result to a variable indicates a return value, and arguments inside the parentheses signify parameters being passed.

 

Question 57. Which of the following calling function have no return value and no argument?
(a) display();
(b) display(x,y);
(c) x = display();
(d) x = display(x,y);
Answer: (a) display();
In simple words: This option shows a function being used that doesn't need any input information (because the parentheses are empty) and also doesn't give back any result (because its output is not stored anywhere). It just does its task.

๐ŸŽฏ Exam Tip: An empty pair of parentheses `()` in a function call indicates that no arguments are being passed, and the absence of an assignment to a variable usually means no value is being returned.

 

Question 58. Which of the following calling the function have no return value and with arguments?
(a) display();
(b) display(x,y);
(c) x = display();
(d) x = display(x,y);
Answer: (b) display(x,y);
In simple words: This option describes using a function where you provide some input values (`x` and `y`), but you don't expect any answer or result to be given back from the function itself. It means the function performs an action but doesn't calculate a value to return.

๐ŸŽฏ Exam Tip: When a function call has arguments but is not assigned to a variable, it typically means it's a `void` function that takes parameters and performs an action.

 

Question 59. Which of the following calling the function have a return value and no argument?
(a) display();
(b) display(x,y);
(c) x = display();
(d) x = display(x,y);
Answer: (c) x = display();
In simple words: This option shows how you can use a function that doesn't need any input from you, but it will give you a result back, and that result will be stored in a variable called `x`.

๐ŸŽฏ Exam Tip: An empty set of parentheses in a function call combined with an assignment to a variable indicates a function that takes no arguments but returns a value.

 

Question 60. .................... are the means to pass values from the calling function to the called function.
(a) Arguments
(b) Parameters
(c) Arguments or Parameters
(d) None of these
Answer: (c) Arguments or Parameters
In simple words: To send information from one part of a program (the calling function) to another part (the called function), you use "arguments" or "parameters." They are like special containers that carry the values.

๐ŸŽฏ Exam Tip: While "arguments" and "parameters" are often used interchangeably, technically, arguments are the values passed during a call, and parameters are the variables that receive these values in the function definition.

 

Question 61. The variables used in the function definition as parameters are known as .................... parameters.
(a) Formal
(b) Actual
(c) Ideal
(d) None of these
Answer: (a) Formal
In simple words: When you set up a function and give it names for the inputs it expects, those input names are called "formal parameters." They are like placeholders for the real values that will come later.

๐ŸŽฏ Exam Tip: Formal parameters are declared in the function header and define the types and names of the inputs the function expects.

 

Question 62. The parameters used in the function call are known as .................... parameters.
(a) Formal
(b) Actual
(c) Ideal
(d) None of these
Answer: (b) Actual
In simple words: When you actually use a function and give it specific values, those real values are called "actual parameters." They are the true inputs that the function will work with.

๐ŸŽฏ Exam Tip: Actual parameters are the concrete values or variables supplied when a function is invoked, and they are passed to the formal parameters.

 

Question 63. The .................... can be used in the function call as parameters.
(a) Constants
(b) Variables
(c) Expressions
(d) All the options
Answer: (d) All the options
In simple words: When you call a function, you can give it fixed numbers (constants), changeable storage spots (variables), or even small calculations (expressions) as inputs. The function can accept any of these types of values.

๐ŸŽฏ Exam Tip: Any valid C++ expression that evaluates to a value compatible with the formal parameter's type can be used as an actual argument in a function call.

 

Question 64. The .................... arguments allow omitting some arguments when calling the function.
(a) Default
(b) Actual
(c) Formal
(d) None of these
Answer: (a) Default
In simple words: If a function has "default arguments," it means you don't always have to provide a value for them when you use the function. If you don't give a value, the function will just use a pre-set value instead.

๐ŸŽฏ Exam Tip: Default arguments must be specified from right to left in the parameter list, meaning all parameters after the first default argument must also have default values.

 

Question 65. The default value is given in the form of ....................
(a) Variable declaration
(b) Variable initialization
(c) void
(d) None of these
Answer: (b) Variable initialization
In simple words: When you set a default value for an argument in a function, it's like giving that argument a starting value right when you define it, just as you would give a starting value to a normal variable.

๐ŸŽฏ Exam Tip: Default argument values are specified in the function prototype or definition (but not both) using the assignment operator.

 

Question 66. The default arguments facilitate the function call statement with .................... arguments.
(a) Partial
(b) No
(c) Complete
(d) All the options
Answer: (d) All the options
In simple words: Default arguments make it easier to use functions because you can call them in many ways: you can skip some arguments (partial), skip all of them if they all have defaults (no arguments), or provide values for every argument (complete).

๐ŸŽฏ Exam Tip: Using default arguments increases the flexibility of a function, allowing it to be called with different numbers of arguments.

 

Question 67. The default values can be included in the function prototype from ....................
(a) Left to Right
(b) Right to Left
(c) Center to Left
(d) None of these
Answer: (b) Right to Left
In simple words: When you set default values for function arguments, you must start from the rightmost argument and move left. You cannot have an argument with a default value followed by an argument without one.

๐ŸŽฏ Exam Tip: This "right-to-left" rule for default arguments is a strict syntactic requirement in C++ and ensures unambiguous function calls.

 

Question 68. The constant variable can be declared using the keyword.
(a) constant
(b) Const
(c) const
(d) CONST
Answer: (c) const
In simple words: To make a variable's value stay fixed and unchangeable throughout a program, you use the special keyword `const` when you create it. This ensures its value cannot be accidentally altered.

๐ŸŽฏ Exam Tip: The `const` keyword is used for compile-time constants, ensuring that the value remains fixed and unalterable after initialization.

 

Question 69. The .................... keyword makes variable value stable.
(a) constant
(b) Const
(c) const
(d) CONST
Answer: (c) const
In simple words: The `const` keyword is used to make sure that a variable's value does not change after it has been set. Once you give it a value, it stays the same, making it "stable."

๐ŸŽฏ Exam Tip: Using `const` for variables and function parameters is good practice for ensuring data integrity and can help the compiler optimize code.

 

Question 70. The .................... modifier enables to assign an initial value to a variable that cannot be changed later inside the body of the function,
(a) void
(b) Const
(c) const
(d) Unsinged
Answer: (c) const
In simple words: The `const` keyword is like a lock that you put on a variable. You can give it an initial value, but once that value is set, it cannot be changed or updated later in the function.

๐ŸŽฏ Exam Tip: A `const` variable must be initialized at the time of its declaration, as its value cannot be modified afterwards.

 

Question 71. In C++, the arguments can be passed to a function in .................... ways.
(a) three
(b) two
(c) four
(d) None of these
Answer: (b) two
In simple words: In C++, you can send information to a function in two main ways: by sending a copy of the value itself, or by sending a special link (address) to where the value is stored.

๐ŸŽฏ Exam Tip: The two fundamental ways to pass arguments are "call by value" and "call by reference" (or "call by address" using pointers).

 

Question 72. In C++, the arguments can be passed to a function in .................... method.
(a) Call by value
(b) Call by reference
(c) Either A or B
(d) None of these
Answer: (c) Either A or B
In simple words: When you send information to a function in C++, you have a choice: you can either send a copy of the actual value (call by value) or send a direct link to where the original value is kept (call by reference). Both methods are common ways to do it.

๐ŸŽฏ Exam Tip: Choose "call by value" when the function only needs to read the argument, and "call by reference" when the function needs to modify the original argument's value.

 

Question 73. method copies the value of an actual parameter into the formal parameter of the function.
(a) Call by value
(b) Call by reference
(c) Either A or B
(d) None of these
Answer: (a) Call by value
In simple words: In the "call by value" method, when you give an input to a function, the function gets its own exact copy of that input. It's like giving someone a photocopy instead of the original document.

๐ŸŽฏ Exam Tip: "Call by value" means that any changes made to the parameter inside the function will not affect the original variable outside the function.

 

Question 74. In .................... method, changes made to the formal parameter within the function will have no effect on the actual parameter.
(a) Call by value
(b) Call by reference
(c) Either A or B
(d) None of these
Answer: (a) Call by value
In simple words: When you use the "call by value" method, the function works with its own separate copy of the input. So, if the function changes that copy, the original value outside the function remains untouched and doesn't change at all.

๐ŸŽฏ Exam Tip: This characteristic of "call by value" makes it safe for functions to manipulate their parameters without concerns of altering external data.

 

Question 75. method copies the address of the actual argument into the formal parameter.
(a) Call by value
(b) Call by reference
(c) Either A or B
(d) None of these
Answer: (b) Call by reference
In simple words: In the "call by reference" method, instead of giving the function a copy of the value, you give it the actual memory location (address) where the original value is stored. This means the function can directly work on and change the original value.

๐ŸŽฏ Exam Tip: "Call by reference" allows a function to directly modify the original variable from the calling scope, making it useful when you need to change multiple values or pass large objects efficiently.

 

Question 76. In the method, any change made in the formal parameter will be reflected back in the actual parameter.
(a) Call by value
(b) Call by reference
(c) Either A or B
(d) None of these
Answer: (b) Call by reference
In simple words: With "call by reference," if the function changes the input value it receives, that change is not just to a copy; it directly alters the original value in the main part of the program. The changes are "reflected back."

๐ŸŽฏ Exam Tip: Use "call by reference" (or pointers for C-style functions) when you intend for a function to modify the actual arguments passed to it.

 

Question 77. The definition of the functions is stored in ............
(a) Array
(b) Call by reference
(c) Structures
(d) None of these
Answer: (b) Call by reference
In simple words: The way a function works is usually stored in the part of a program that manages "call by reference." This means the function uses the memory location of variables directly.

๐ŸŽฏ Exam Tip: Understanding where function definitions are stored helps in debugging and optimizing program memory usage.

 

Question 78. ............ functions can be used to reduce the overheads like STACKS for small function definition.
(a) Inline
(b) Built-in
(c) User-defined
(d) None of these
Answer: (a) Inline
In simple words: Inline functions help make programs faster by putting the function's code directly into where it's called, avoiding the extra work of a normal function call. They are best for small functions.

๐ŸŽฏ Exam Tip: Inline functions are a performance optimization feature in C++ that can improve execution speed for very small functions by eliminating function call overhead.

 

Question 79. ............ reduces the speed of program execution.
(a) Array
(b) Stacks
(c) Structures
(d) Unions
Answer: (b) Stacks
In simple words: When a program uses a lot of "stacks" (a way to store data temporarily), it can sometimes slow down the program. This is because managing the stack takes time.

๐ŸŽฏ Exam Tip: While stacks are essential for managing function calls and local variables, excessive recursion or large local data can lead to stack overflow or performance degradation.

 

Question 80. A(n) ............ function looks like a normal function in the source file but inserts the function's code directly into the calling program.
(a) inline
(b) Built-in
(c) User-defined
(d) None of these
Answer: (a) inline
In simple words: An inline function is a special type of function where the compiler replaces the function call with the actual code of the function. This makes the program run quicker because it saves the time it takes to jump to and from the function.

๐ŸŽฏ Exam Tip: Inline functions are a good choice for short, frequently used functions to avoid the overhead of function calls.

 

Question 81. To make a function inline, one has to insert the keyword ............ in the function header.
(a) Inline
(b) Insert
(c) INLINE
(d) None of these
Answer: (a) Inline
In simple words: To tell the compiler that you want a function to be inline, you need to put the word "inline" before its name in the header. This signals the compiler to try and directly embed the function's code.

๐ŸŽฏ Exam Tip: The `inline` keyword is a request to the compiler, not a command; the compiler may choose to ignore it for various reasons, especially if the function is too large or complex.

 

Question 82. ............ functions execute faster but require more memory space.
(a) User-defined
(b) Built-in
(c) Inline
(d) None of these
Answer: (c) Inline
In simple words: Inline functions run faster because their code is placed directly in the main program. However, this means the program might become larger, using more memory space.

๐ŸŽฏ Exam Tip: The trade-off between speed and memory for inline functions is important; use them judiciously for small functions.

 

Question 83. The inline function reduces the complexity of using ............
(a) Array
(b) Stacks
(c) Structures
(d) Unions
Answer: (b) Stacks
In simple words: Inline functions can make programs simpler by reducing the need for "stacks." Stacks are used to remember where to return after a function call, and inline functions avoid this.

๐ŸŽฏ Exam Tip: Inline functions help reduce the overhead associated with function calls, including the management of the call stack.

 

Question 84. Returning from the function is done by using the ............ statement.
(a) return
(b) goto
(c) break
(d) continue
Answer: (a) return
In simple words: When a function finishes its job and needs to give control back to where it was called, it uses the "return" command. This command helps the program move forward.

๐ŸŽฏ Exam Tip: The `return` statement is crucial for exiting functions and optionally sending a value back to the caller.

 

Question 85. The ............ statement stops execution and returns to the calling function.
(a) return
(b) goto
(c) break
(d) continue
Answer: (a) return
In simple words: The "return" statement acts like an exit sign for a function. When the program reaches it, the function stops running and the program goes back to the part that asked the function to start.

๐ŸŽฏ Exam Tip: A function can have multiple return statements, but only the first one encountered during execution will be processed.

 

Question 86. Identify the true statement from the following.
(a) A return may or may not have a value associated with it.
(b) If the return has a value associated with it, that value becomes the return value for the calling statement.
(c) The return statement is used to return from a function.
(d) All of the options
Answer: (d) All of the options
In simple words: All the given statements about how the "return" command works are true. It can send back a value or nothing, it sends the value to the part of the code that called it, and its main job is to exit the function.

๐ŸŽฏ Exam Tip: Remember that the `return` statement is versatile; it can terminate a `void` function without a value or pass a specified value from a non-`void` function.

 

Question 87. The functions that return no value are declared as ............
(a) Null
(b) void
(c) Empty
(d) None of these
Answer: (b) void
In simple words: Functions that do not give back any result after they finish their work are marked with the special word "void". This tells the computer not to expect any output from them.

๐ŸŽฏ Exam Tip: Using `void` as a return type is essential for functions that perform actions but don't produce a specific computational result.

 

Question 88. The data type of a function is treated as ............ if no data type is explicitly mentioned.
(a) Null
(b) void
(c) Empty
(d) int
Answer: (d) int
In simple words: If you forget to tell the computer what kind of data a function will return, the computer will automatically assume it will return a whole number, or "int". This is like a default setting.

๐ŸŽฏ Exam Tip: Always explicitly declare the return type of a function to avoid implicit type assumptions, which can sometimes lead to unexpected behavior or errors.

 

Question 89. What is the return type of the following function prototype? add (int, int);
(a) Null
(b) void
(c) Empty
(d) int
Answer: (d) int
In simple words: In the function `add (int, int);`, the computer expects the function to give back a whole number. This is because no other type is mentioned, so "int" is the default.

๐ŸŽฏ Exam Tip: When a return type is omitted in a function prototype in older C++ standards, `int` is assumed; however, it's best practice to always specify the return type for clarity.

 

Question 90. What is the return type of the following function prototype? double add (int, int);
(a) float
(b) void
(c) double
(d) int
Answer: (c) double
In simple words: For the function `double add (int, int);`, the word "double" at the start tells us that this function will return a number with decimal points. This allows for more precise results.

๐ŸŽฏ Exam Tip: The return type `double` is used for floating-point numbers with higher precision than `float`.

 

Question 91. What is the return type of the following function prototype? char *display();
(a) float
(b) string
(c) double
(d) char
Answer: (b) string
In simple words: The `char *` part in `char *display();` means the function will return a pointer to a character, which is typically used to represent a string of characters in C++. This means it is expected to return a sequence of text.

๐ŸŽฏ Exam Tip: In C++, `char *` is often used to handle C-style strings, which are sequences of characters terminated by a null character.

 

Question 92. A function that calls itself is known as ............ function.
(a) recursive
(b) nested
(c) invariant
(d) variant
Answer: (a) recursive
In simple words: A special kind of function that calls itself to solve a problem is called a "recursive" function. It keeps calling itself until a simple base case is met.

๐ŸŽฏ Exam Tip: Recursive functions are powerful for solving problems that can be broken down into smaller, similar sub-problems, like calculating factorials or navigating tree structures.

 

Question 93. A function that calls itself using ............ technique.
(a) recursive
(b) variant
(c) invariant
(d) recursion
Answer: (d) recursion
In simple words: The method or approach where a function calls itself is known as "recursion." This technique is very useful for certain types of problems.

๐ŸŽฏ Exam Tip: Recursion is a programming technique; a function is recursive if it directly or indirectly calls itself.

 

Question 94. ............ is mandatory when a function is defined after the main() function.
(a) Function prototype
(b) Function parameters
(c) Return statement
(d) None of these
Answer: (a) Function prototype
In simple words: If you write a function after the `main()` part of your program, you must first tell the compiler about it using a "function prototype." This is like a forward declaration so the compiler knows what to expect.

๐ŸŽฏ Exam Tip: A function prototype (or declaration) informs the compiler about a function's name, return type, and parameters, ensuring proper usage before its actual definition is encountered.

 

Question 95. Scope refers to the accessibility of a ............
Answer: (c) Variable
In simple words: "Scope" tells us where in a program a "variable" can be seen and used. It defines the area where a variable is valid.

๐ŸŽฏ Exam Tip: Scope is a fundamental concept in programming that determines the visibility and lifetime of identifiers, such as variables and functions.

 

Question 96. There are ............ types of scopes in C++.
(a) five
(b) two
(c) three
(d) four
Answer: (d) four
In simple words: In C++, there are four main types of places where you can declare things, and each place has its own "scope." These scopes define how long and where variables can be used.

๐ŸŽฏ Exam Tip: The four primary scopes in C++ are local (block), function, file (global), and class scope, each with specific rules for variable visibility.

 

Question 97. ............ is a type of variable scope.
(a) Local
(b) Function / File
(d) Class
(d) All of the options
Answer: (d) All of the options
In simple words: Local, Function/File, and Class are all different types of "variable scope." Each one describes where a variable can be seen and used in a program.

๐ŸŽฏ Exam Tip: Knowing the different types of scopes is crucial for managing variable visibility and avoiding naming conflicts in larger programs.

 

Question 98. A ............ is a region or life of the variable and broadly speaking there are three places, where variables can be declared.
Answer: (a) Scope
In simple words: A "scope" is the area in a program where a variable exists and can be used. It also defines how long that variable lives. There are three main places where variables can be set up.

๐ŸŽฏ Exam Tip: The concept of scope directly impacts variable lifetime and can prevent unintended modifications or access outside defined boundaries.

 

Question 99. Variables inside a block are called ............ variables.
(a) Local
(b) Function
(c) Class
(d) File
Answer: (a) Local
In simple words: Variables that are created inside a small section of code, like within `{}` brackets, are called "local" variables. They can only be used within that small section.

๐ŸŽฏ Exam Tip: Local variables are often preferred for temporary data storage as they are created and destroyed with the block, minimizing memory footprint and potential side effects.

 

Question 100. Variables inside a function are called ............ variables.
(a) Local
(b) Function
(c) Class
(d) File
Answer: (b) Function
In simple words: Variables created inside a function are known as "function" variables. They can only be used by that specific function and disappear once the function finishes.

๐ŸŽฏ Exam Tip: Function-scope variables are ideal for data needed only during a specific function's execution, promoting encapsulation.

 

Question 101. Variables outside of all functions are called ............ variables.
(a) Local
(b) Function
(c) Class
(d) Global
Answer: (d) Global
In simple words: Variables that are declared outside of any function, at the very top of your program, are called "global" variables. They can be seen and used by any part of the program.

๐ŸŽฏ Exam Tip: Global variables should be used sparingly, as they can make code harder to debug and maintain due to their widespread accessibility.

 

Question 102. Variables inside a class are called ............
(a) Class variable
(b) Data members
(c) Member functions
(d) Both (a) and (b)
Answer: (d) Both (a) and (b)
In simple words: The variables that are part of a "class" are called "class variables" or "data members." They store information for objects created from that class.

๐ŸŽฏ Exam Tip: In object-oriented programming, data members define the state of an object, while member functions define its behavior.

 

Question 103. The scope of formal parameters is ............
(a) Local
(b) Function
(c) Class
(d) File
Answer: (b) Function
In simple words: The "formal parameters" (the variables listed in a function's definition) can only be used inside that function. So, their scope is limited to the function itself.

๐ŸŽฏ Exam Tip: Formal parameters are local to the function they belong to; changes to them do not affect the original arguments in the calling function (unless passed by reference).

 

Question 104. A variable declared above all blocks and functions (including main ()) has the ............ scope.
(a) Local
(b) Function
(c) Class
(d) File
Answer: (d) File
In simple words: A variable that is put at the very top of a code file, before any functions or blocks, has a "file scope." This means it can be used anywhere in that specific file.

๐ŸŽฏ Exam Tip: Variables with file scope are often called global variables and can be accessed from any function within the same file after their declaration.

 

Question 105. The lifetime of a ............ scope variable is the lifetime of a program.
(a) Local
(b) Function
(c) Class
(d) File
Answer: (d) File
In simple words: A variable with "file scope" lives for as long as the entire program is running. It is created when the program starts and is destroyed when the program ends.

๐ŸŽฏ Exam Tip: Understanding variable lifetime is crucial for memory management and ensuring data persistence when needed, and proper cleanup when no longer required.

 

Question 106. The file scope variable is also called as ............ variable.
(a) Global
(b) General
(c) Void
(d) None of these
Answer: (a) Global
In simple words: A variable that has "file scope," meaning it can be used anywhere in the file, is also known as a "global" variable. It is accessible throughout the program.

๐ŸŽฏ Exam Tip: Global variables are accessible throughout the entire program's execution, which can be useful for shared data but also risky if not managed carefully.

 

Question 107. ............ provides a method for packing together data of different types.
(a) Enumeration
(b) Array
(c) Class
(d) All of the options
Answer: (c) Class
In simple words: A "class" is like a blueprint that lets you put different kinds of data (like numbers, words, etc.) together into one neat package. It helps organize related information.

๐ŸŽฏ Exam Tip: Classes are fundamental to object-oriented programming, enabling data encapsulation and creating custom data types.

 

Question 108. ............ represent the features or properties of a class.
(a) Member function
(b) Data member
(c) Global variable
(d) None of these
Answer: (b) Data member
In simple words: The "data members" are the variables inside a class that describe its characteristics or what it's made of. They hold the information that defines an object.

๐ŸŽฏ Exam Tip: Data members (also known as attributes or properties) store the state of an object, while member functions (methods) define its behavior.

 

Question 109. ............ is a scope resolution operator.
(a) ? :
(b) #
(c) ::
(d) &&
Answer: (c) ::
In simple words: The `::` symbol is a special tool called the "scope resolution operator." It helps you tell the computer exactly which version of a variable or function you want to use, especially if there are many with the same name.

๐ŸŽฏ Exam Tip: The scope resolution operator `::` is vital for accessing global variables when a local variable with the same name exists, or for defining member functions outside a class declaration.

 

Question 110. The ............ operator reveals the hidden scope of a variable.
(a) ? :
(b) &&
(c) ::
(d) #
Answer: (c) ::
In simple words: The `::` symbol is an operator that helps uncover a variable's hidden meaning or "scope." It lets you use a variable even if another one with the same name is currently active.

๐ŸŽฏ Exam Tip: This operator is frequently used with namespaces and classes to specify which declaration of a name is being referred to.

Very Short Answers (2 Marks)

 

Question 1. Write about reusability.
Answer: Reusability means that you can use the same code parts again and again in different places. This helps in two ways:
1. You don't have to write the same code many times. Using functions for repeated tasks makes programs easier to fix and smaller in size. This also helps reduce human errors when coding.
2. Some functions can be used multiple times, even with different information fed into them. This flexibility saves a lot of time.
In simple words: Reusability means using the same code or functions again instead of writing new ones. It makes programs smaller and easier to manage.

๐ŸŽฏ Exam Tip: Always highlight that code reusability improves maintainability, reduces development time, and decreases the chance of errors by using well-tested components.

 

Question 2. Why functions are needed?
Answer: Functions are needed to make programs smaller and less complicated. They help by breaking a big program into smaller, easier-to-handle parts. Each part can then do a specific job. This approach makes it easier to understand the program, test it for mistakes, and fix any problems. Functions are essential for writing organized and efficient code.
In simple words: Functions are needed to make programs simpler, smaller, and easier to manage. They help break big tasks into small, clear steps.

๐ŸŽฏ Exam Tip: When explaining the need for functions, emphasize modularity, abstraction, and efficiency as key benefits.

 

Question 3. What are constant arguments and write their syntax?
Answer: Constant arguments are special values given to a function that cannot be changed inside that function. You use the `const` keyword to declare them. This makes the variable's value stable and unchanging. It is important to set their value when you first declare them. The `const` word makes sure that the variable keeps its initial value and cannot be modified later within the function's code.
Syntax: `(const )`
Example: `int minimum(const int a=10);`
`float area(const float pi=3.14, int r=5);`
In simple words: Constant arguments are values given to a function that cannot be changed inside it. The word `const` is used to make them stable.

๐ŸŽฏ Exam Tip: Explain that using `const` arguments helps prevent accidental modification of important values within a function, ensuring data integrity.

 

Question 4. Write a note on the reusability of the code.
Answer: Code reusability means that parts of a program can be used repeatedly in different situations without needing to be rewritten. This brings several benefits:
1. It helps remove duplicate code. By using functions for common tasks, the program becomes easier to maintain and its overall size is reduced.
2. Functions can be called multiple times with different inputs, making the code more flexible and efficient. This saves time and effort during development.
In simple words: Reusability means you can use the same pieces of code (like functions) many times. This makes programs shorter and easier to handle because you don't write the same things over and over.

๐ŸŽฏ Exam Tip: Focus on how reusability leads to more efficient development cycles and more reliable software due to reusing already debugged code.

 

Question 5. What is function scope?
Answer: Function scope refers to where variables declared within a function can be accessed. Here are its key points:
1. The variables defined inside a function can be used throughout that function, including any smaller blocks of code within it. They are "visible" everywhere in the function.
2. A variable with function scope exists only for the duration that the function is running. It is created when the function starts and is removed when the function finishes. After the function ends, the variable is gone.
In simple words: Function scope means a variable can only be used inside the function where it was made. It lives only as long as that function runs.

๐ŸŽฏ Exam Tip: Emphasize that variables declared within a function are local to that function and cannot be accessed from outside it, promoting isolation and preventing interference.

 

Question 6. What is the header file?
Answer: A header file is like a special collection of pre-written functions that C++ provides. These functions are ready to be used for various tasks. Programmers don't have to write these basic functions themselves. The code for these functions is already written and checked for errors. Their definitions are grouped and stored in special files called header files. You need to include these files in your program to use their functions.
In simple words: Header files contain pre-written functions that you can use in your C++ programs. You include them to easily use common tools.

๐ŸŽฏ Exam Tip: Mention common header files like `iostream` for input/output and `cmath` for mathematical functions to illustrate their practical use.

 

Question 7. What is a built-in function?
Answer: A built-in function is a function that is already provided by the programming language (like C++). These are pre-defined subprograms that are ready to use. You don't have to write the code for them yourself; you just call them by their names. Examples include functions for doing math or handling text. They save time and ensure consistent behavior because they are already tested and reliable.
In simple words: Built-in functions are ready-made tools that come with the programming language. You just use them without writing their code.

๐ŸŽฏ Exam Tip: Highlight that built-in functions are part of the standard library and are essential for performing common operations efficiently without reinventing the wheel.

 

Question 8. What is a user-defined function?
Answer: A user-defined function is a function that a programmer creates to perform a specific task according to their own needs. C++ allows programmers to make new functions. The programmer decides what the function will do, what information it needs, and what kind of result it will give. Since the user defines these tasks, they are called user-defined functions. They help customize the program's behavior.
In simple words: User-defined functions are made by programmers to do specific jobs in their own way. They help customize programs.

๐ŸŽฏ Exam Tip: Contrast user-defined functions with built-in functions to show how they offer flexibility and allow programmers to solve unique problems.

 

Question 9. How a header file is identified?
Answer: A header file can be easily identified by its special file extension: `.h`. This `.h` at the end of the file name tells you that it contains declarations of functions and variables. For example, `stdio.h` is a common header file. When you see a file name ending with `.h`, you know it is a header file that you can include in your C++ programs.
Example: `stdio.h`
In simple words: Header files are identified by their file name ending with `.h`, like `stdio.h`.

๐ŸŽฏ Exam Tip: Mention that some C++ header files (like `iostream`) are used without the `.h` extension and are part of the C++ Standard Library, while C-style headers retain `.h`.

 

Question 10. Write note on stdio.h header file.
Answer: The `stdio.h` header file is a very important part of C programming, and it is also used in C++. It contains definitions for standard input/output functions. These functions help your program talk to the user, like reading things typed on the keyboard or showing things on the screen. Some examples of functions defined in `stdio.h` include `getchar()`, `putchar()`, `gets()`, and `puts()`. This file is crucial for basic communication in console applications.
In simple words: The `stdio.h` file has common input/output functions like `getchar()` and `puts()`, which help programs read from and write to the screen.

๐ŸŽฏ Exam Tip: Emphasize that `stdio.h` is a C-style header, and while usable in C++, `iostream` is the preferred C++ alternative for type-safe I/O operations.

 

Question 11. What is the purpose of getchar() and putchar() functions?
Answer: The `getchar()` and `putchar()` functions are used for single-character input and output. The `getchar()` function is used to get just one character from the keyboard. When a user types a character, `getchar()` reads it into the program. On the other hand, the `putchar()` function is used to display a single character on the screen. If you want to show just one letter or symbol, `putchar()` is the function to use. These are basic but fundamental I/O operations.
In simple words: `getchar()` reads one character from the keyboard, and `putchar()` shows one character on the screen.

๐ŸŽฏ Exam Tip: These functions are useful for basic character-by-character processing, especially when working with raw input streams or character arrays.

 

Question 12. What is the purpose of gets() and puts() functions?
Answer: The `gets()` and `puts()` functions are used for handling strings (sequences of characters). The `gets()` function reads a complete string from the standard input (like the keyboard), even if it contains spaces. It continues reading until a newline character is encountered. The input string is then stored in a variable. The `puts()` function, conversely, prints a string to the standard output (like the screen). It also adds a new line at the end of the printed string automatically. These functions are useful for displaying and capturing whole lines of text.
In simple words: `gets()` reads a whole line of text, including spaces, from the keyboard and `puts()` prints a line of text to the screen, adding a new line at the end.

๐ŸŽฏ Exam Tip: Warn about the security risks of `gets()` (buffer overflow) and suggest using safer alternatives like `fgets()` or `getline()` for string input.

 

Question 13. Write note on isalpha() function.
Answer: The `isalpha()` function checks if a given character is an alphabet (a letter) or not. If the character is a letter, this function gives back a value of 1. If it is not a letter, it gives back 0. For example, if we check the character '3', the function will return 0 because '3' is a number, not a letter. This helps programs categorize different types of input characters.
Syntax: `int isalpha(char c);`
This function will return 1 if the given character is an alphabet, and 0 otherwise.
The following statement assigns 0 to the variable n, since the given character is not an alphabet.
`int n = isalphaC3');`
The statement is given below displays 1, since the given character is an alphabet.
`cout << isalpha('a'); .`
In simple words: The `isalpha()` function tells you if a character is a letter from the alphabet. It returns 1 for a letter and 0 for anything else.

๐ŸŽฏ Exam Tip: Remember `isalpha()` only checks for alphabetic characters; it doesn't distinguish between uppercase and lowercase letters itself. For that, you would use `isupper()` or `islower()`.

 

Question 14. Write the use of isdigit() function.
Answer: The `isdigit()` function is used to find out if a specific character is a number (digit) or not. It gives back a value of 1 if the character is a digit, and 0 if it is anything else. This function is very useful for checking data input, making sure users enter numbers when expected.
Syntax: `int isdigit(char c);`
When the following code is run, the variable `n` will get the value 1, because the character `ch` ('3') is a digit.
`char ch = '3';`
`n = isdigit (ch);`
In simple words: The `isdigit()` function checks if a character is a number. It returns 1 if it is a number and 0 if it is not.

๐ŸŽฏ Exam Tip: When working with character input, always use `isdigit()` to validate if the input is a number before performing any mathematical operations to prevent errors.

 

Question 15. How to copy a string into another string?
Answer: To copy one string into another, you use the `strcpy()` function. This function takes the content of the "source" string and places it into the "target" string's memory location. It also copies the special null character `(\0)` which marks the end of a string. This ensures the copied string is correctly terminated.
The `strcpy()` function needs two arguments: the target string and the source string.
Example:
`char source[] = "Computer Science";`
`char target[20]="target";`
`strcpy(target, source);`
In simple words: The `strcpy()` function makes an exact copy of one string and puts it into another string. It copies all characters, including the one that signals the end of the string.

๐ŸŽฏ Exam Tip: Always make sure the target string has enough space to hold the copied source string to prevent buffer overflows, which can lead to security vulnerabilities.

 

Question 16. What is the purpose of strupr() and strlwr() functions?
Answer: The `strupr()` and `strlwr()` functions are used to change the case of characters within a string.
The `strupr()` function takes a string and converts all its alphabetic characters into uppercase letters. For example, "hello" becomes "HELLO". This is useful for standardizing text or for case-insensitive comparisons.
The `strlwr()` function does the opposite; it converts all alphabetic characters in a given string into lowercase letters. For example, "HELLO" becomes "hello". Both functions modify the original string directly.
In simple words: `strupr()` changes all letters in a string to capital letters, and `strlwr()` changes them all to small letters.

๐ŸŽฏ Exam Tip: Remember that `strupr()` and `strlwr()` modify the original string in place. If you need the original string later, make a copy before using these functions.

 

Question 17. What is the use of return statement in a function?
Answer: The `return` statement is used to finish a function's execution and send control back to the part of the program that called it. When a `return` statement is run, the function stops immediately at that point. It can also send a value back to the calling part of the program. This statement is a type of jump statement because it ends the function's task and passes control to another part of the code.
In simple words: A `return` statement stops a function and can send a value back to where the function was called from.

๐ŸŽฏ Exam Tip: A function can have multiple `return` statements, but only one is executed during any single call. Always ensure all possible execution paths lead to a `return` statement if the function is declared to return a value.

 

Question 18. Write note on scope resolution operator.
Answer: The scope resolution operator `(::)` helps a program know which variable you are referring to, especially when there are multiple variables with the same name in different "scopes" or areas of the program. It "reveals" a hidden variable's scope. This operator is used for a few main purposes.
It allows you to access a global variable when there is a local variable with the same name. Without it, the local variable would be used by default.
An example using the Scope Resolution Operator:
PROGRAM:
`#include `
`using namespace std;`
`int x=45; // Global Variable x`
`int main()`
`{`
`int x = 10; // Local Variable x`
`cout << "\nValue of global x is " << ::x;`
`cout << "\nValue of local x is " << x;`
`return 0;`
`}`
Output:
Value of global x is 45
Value of local x is 10
In simple words: The scope resolution operator `(::)` is used to specify which variable you mean when there are two variables with the same name in different parts of your program (like a global one and a local one).

๐ŸŽฏ Exam Tip: The scope resolution operator is crucial in C++ for distinguishing between global variables and local variables that share the same identifier, ensuring the correct variable is accessed.

Short Answers (3 Marks)

 

Question 1. What is divide and conquer?
Answer: Divide and conquer is a programming strategy where complex tasks are broken down into smaller, simpler parts called functions.
1. Large, complex programs can be split into smaller, manageable pieces (sub-programs) known as functions.
2. This approach lets a programmer focus on writing, fixing, and testing each individual function separately.
3. It also means that several programmers can work on different functions at the same time, which makes the development faster.
In simple words: "Divide and conquer" means breaking a big, difficult program into many small, easier parts (functions) to make it simpler to build and fix.

๐ŸŽฏ Exam Tip: Emphasize that "divide and conquer" improves program organization, reusability, and maintainability by breaking down complex problems into manageable functions.

 

Question 2. Write about islower() function.
Answer: The `islower()` function checks if a character is a lowercase alphabet (a small letter) or not. It gives a non-zero value (usually 1) if the character is a lowercase letter, and 0 if it is not. This is helpful when you need to confirm that input is in lowercase or to perform operations based on character case.
Syntax: `int islower(char c);`
After running the following statements, the variable `n` will have the value 1 because 'n' is a lowercase letter.
`char ch = 'n';`
`int n = islower(ch);`
The statement below will set `n` to 0, because 'P' is an uppercase letter, not lowercase.
`int n = islower('P');`
In simple words: The `islower()` function tells you if a character is a small letter. It gives 1 if it is, and 0 if it is not.

๐ŸŽฏ Exam Tip: When using `islower()`, remember it only checks for alphabetic lowercase characters. Numbers or symbols will return false, as they are neither uppercase nor lowercase letters.

 

Question 3. What is digit()? Give example.
Answer: The `isdigit()` function is used to check if a specific character is a number (a digit) or not. If the character is a digit (0-9), this function returns a value of 1. If it's not a digit, it returns 0. This is useful for validating user input to ensure that only numbers are entered when needed.
Example:
`using namespace std;`
`#include`
`#include int main()`
`{`
`char ch;`
`cout << "\n Enter a Character:"; cin >> ch;`
`cout << "\n The Return Value of isdigit(ch) is " << isdigit(ch);`
`}`
Output - 1
Enter a Character: 3
The Return Value of isdigit(ch) is: 1
Output - 2
Enter a Character: A
The Return Value of isdigit(ch) is: 0
In simple words: The `isdigit()` function checks if a character is a number. It returns 1 for a number and 0 for anything else.

๐ŸŽฏ Exam Tip: Always include `` (or `` in C) when using character handling functions like `isdigit()` to ensure they are properly declared and available.

 

Question 4. Explain the method of comparing two strings.
Answer: To compare two strings, you use the `strcmp()` function. This function looks at the contents of the first string and the second string character by character, in alphabetical order (this is called lexicographical comparison). It checks their ASCII values.
The `strcmp()` function takes two arguments: string1 and string2.
The `strcmp()` function returns:
- A positive value if the first differing character in string1 has a greater ASCII value than the corresponding character in string2.
- A negative value if the first differing character in string1 has a smaller ASCII value than the corresponding character in string2.
- 0 if string1 and string2 are exactly the same.
Example:
`#include `
`#include `
`using namespace std;`
`int main()`
`{`
`char string1[] = "Computer";`
`char string2[] = "Science";`
`int result;`
`result = strcmp(string1,string2);`
`if(result==0)`
`{`
`cout<<"String1: "<`}`
`else`
`{`
`cout<<"String1 :"<`}`
`}`
Output
String 1: Computer and String2: Science Are Not Equal
In simple words: The `strcmp()` function compares two strings letter by letter. It returns 0 if they are the same, a positive number if the first string comes later alphabetically, and a negative number if the first string comes earlier.

๐ŸŽฏ Exam Tip: Remember to include `` (or `` in C++) when using string manipulation functions like `strcmp()`.

 

Question 5. What is a return statement with an example?
Answer: A `return` statement is used to stop a function from running and send control back to the part of the program that called it. When a `return` statement is run, the function immediately ends. It can also send a value back to the caller. This is considered a "jump statement" because it shifts the program's flow of control.
Example:
`return(a + b);` // This returns the sum of a and b.
`return(a);` // This returns the value of a.
`return;` // This just ends the function without returning a value (for `void` functions).
In simple words: The `return` statement stops a function and can send a value back to the main program.

๐ŸŽฏ Exam Tip: Ensure that the type of value returned by a function matches its declared return type; otherwise, the compiler might issue a warning or an error.

 

Question 6. Write note on sin() and cos() functions.
Answer: The `sin()` and `cos()` functions are mathematical functions used to calculate the sine and cosine of an angle, respectively. These functions take a single argument, which must be in radians, not degrees. Both functions return a value that falls within the range of -1 to 1. The result can be of type double, float, or long double. These are very important in trigonometry and physics calculations.
Example (for `cos()`):
`#include `
`#include `
`using namespace std;`
`int main()`
`{`
`double x = 0.5, result;`
`result = cos(x);`
`cout << "COS("<`}`
Output
COS(0.5)= 0.877583
Example (for `sin()`):
The `sin()` function takes a single argument in radians. The `sin()` function returns the value in the range of [-1, 1]. The returned value is either in double, float, or long double.
In simple words: `sin()` and `cos()` are math functions that find the sine and cosine of an angle. The angle must be in radians, and the answer will always be between -1 and 1.

๐ŸŽฏ Exam Tip: Always remember to convert angles from degrees to radians before using `sin()` or `cos()` functions in C++ by multiplying the degree value by `M_PI / 180.0` (from ``).

 

Question 7. Write about sqrt() and pow() functions.
Answer: The `sqrt()` and `pow()` functions are mathematical tools used for square roots and exponents, respectively.
`sqrt()` function: This function gives back the square root of a given number. It takes only one argument, which must be a non-negative number. If you give it a negative number, it will cause a "domain error". This is because the square root of a negative number is not a real number.
Example:
`#include `
`#include `
`using namespace std;`
`int main()`
`{`
`double x = 625, result;`
`result = sqrt(x);`
`cout << "sqrt("<`return 0;`
`}`
Output
sqrt(625) = 25
`pow()` function: This function calculates the base number raised to the power of an exponent. For example, `pow(5, 4)` means 5 raised to the power of 4. If any argument given to `pow()` is a `long double`, then the result type will also be a `long double`; otherwise, it will be a `double`.
The `pow()` function takes two arguments:
- `base` - the starting value
- `exponent` โ€“ the power to which the base is raised.
Example:
`#include `
`#include `
`using namespace std;`
`int main ()`
`{`
`double base, exponent, result;`
`base = 5;`
`exponent = 4;`
`result = pow(base, exponent);`
`cout << "pow("<< base << "^" << exponent << ") = " << result;`
`double x = 25;;`
`result = sin(x);`
`cout << "\nsin("<`return 0;`
`}`
Output
pow(5^4) = 625
sin(25)= -0.132352
In simple words: The `sqrt()` function finds the square root of a number, which must not be negative. The `pow()` function raises one number (base) to the power of another number (exponent).

๐ŸŽฏ Exam Tip: Both `sqrt()` and `pow()` functions require the `` (or `` in C) header file to be included in your program.

 

Question 8. How will you generate a random numbers?
Answer: To generate random numbers in C++, you primarily use the `rand()` and `srand()` functions. The `rand()` function produces a pseudo-random number, meaning it seems random but follows a pattern. The `srand()` function is used to "seed" (initialize) this random number generator.
By default, if `srand()` is not called, `rand()` acts as if it was seeded with 1, which means it will always produce the same sequence of "random" numbers each time the program runs. To get different sequences, `srand()` needs to be called with a different seed value each time. A common practice is to use the current time (e.g., `time(0)`) as the seed, because it changes constantly. The `srand()` function takes an unsigned integer as its parameter and is defined in the `` (or ``) header file.
Example:
`#include `
`#include `
`using namespace std;`
`int main()`
`{`
`int random = rand(); /* No srand() calls before rand(), so seed = 1 */`
`cout << "\nSeed = 1, Random number = " << random;`
`srand(10);`
`/* Seed= 10 */`
`random = rand();`
`cout << "\n\nSeed = 10, Random number=" << random;`
`return 0;`
`}`
Output
Seed = 1, Random number = 41
Seed = 10, Random number =71
In simple words: To get different "random" numbers each time, you use `rand()` to generate them and `srand()` to give a new starting point (seed), often using the current time.

๐ŸŽฏ Exam Tip: Always call `srand()` only once at the beginning of your `main()` function, typically with `time(0)` as the seed, to ensure a truly varied sequence of random numbers.

 

Question 9. Write note on function prototype.
Answer: A function prototype is like a blueprint for a function, telling the compiler important information about it before the function is actually defined. In C++ programs, you can have many functions, but there must always be exactly one `main()` function to start the program. Functions can be defined in any order. However, a function must be declared (using its prototype) before it is used anywhere else in the program. This declaration can be placed outside the `main()` function.
The prototype provides details such as the function's return data type, its name, and a list of its formal parameters (arguments), including their types and order.
Example:
`long fact (int, double);`
This prototype tells the compiler:
1. The function returns a `long` value.
2. The function's name is `fact`.
3. The function expects two arguments: the first is an `int`, and the second is a `double`.
In simple words: A function prototype is a declaration that tells the computer a function's name, what kind of value it will give back, and what types of information it needs, all before the function is fully written out.

๐ŸŽฏ Exam Tip: Function prototypes are essential for compiler checking (type safety) and allow you to define functions after `main()` or in separate files, promoting modular programming.

 

Question 10. Explain Formal and Actual Parameters or Arguments.
Answer: Parameters (or arguments) are the pieces of information passed from one function to another. When a function is called, it often needs specific data to perform its task, and this data is provided through parameters.
There are two main types:
1. **Formal Parameters:** These are the variables listed in the function's definition. They act as placeholders for the values that will be passed into the function when it is called. For example, in `int sum(int x, int y)`, `x` and `y` are formal parameters. They define what kind of data the function expects.
2. **Actual Parameters:** These are the actual values or expressions used when you call a function. They are the specific pieces of data that are sent to the function. For example, in `sum(5, 10)`, `5` and `10` are actual parameters.
In simple words: Formal parameters are placeholders in a function's definition, while actual parameters are the real values you send to the function when you use it.

๐ŸŽฏ Exam Tip: Ensure that the data types and order of actual parameters match those of the formal parameters in the function's prototype and definition to avoid compilation errors.

Explain in Detail (5 Marks)

 

Question 1. Explain about generating random numbers with a suitable program.
Answer: Generating random numbers in C++ involves using the `rand()` and `srand()` functions. The `rand()` function produces a sequence of pseudo-random numbers. These numbers appear random but are actually generated by a mathematical algorithm, meaning they will repeat the same sequence if started from the same point.
To get a different sequence of numbers each time your program runs, you need to "seed" the random number generator using `srand()`. If `srand()` is not called, `rand()` uses a default seed of 1, resulting in the same "random" sequence every time. By passing a unique value to `srand()`, you change the starting point of the sequence. A common way to get a different seed is to use the current system time (e.g., `time(0)`), which changes constantly. Both `rand()` and `srand()` are part of the `` (or ``) header file.
Program Example:
`#include `
`#include `
`using namespace std;`
`int main()`
`{`
`int random = rand(); /* No srand() calls before rand(), so seed = 1*/`
`cout << "\nSeed = 1, Random number =" << random;`
`srand(10);`
`/* Seed= 10 */`
`random = rand();`
`cout << "\n\n Seed =10, Random number =" << random;`
`return 0;`
`}`
Output:
Seed = 1, Random number = 41
Seed = 10, Random number 71
This example shows how different seed values produce different starting random numbers.
In simple words: To make random numbers in C++, you use `rand()`. To make sure these numbers are different each time you run the program, you use `srand()` and give it a changing number, like the current time.

๐ŸŽฏ Exam Tip: For truly unpredictable random numbers, ensure `` (for `time()`) is included along with ``, and `srand(time(0))` is called once at the start of your program.

 

Question 2. How will access function? Explain in detail.
Answer: To use a user-defined function, it must be "called" from another part of the program, such as the `main()` function. When you call a function, you use its name followed by the necessary arguments (if any) inside parentheses. The compiler then checks the function's prototype to make sure the function call is correct, verifying that the arguments passed match the expected data types and order.
If the data types of the arguments in the function call do not exactly match those defined in the prototype, the compiler will try to convert them if possible. However, if the conversion is not possible, the compiler will show an error message.
Example:

Function CallDescription
1.`display()`Calls the function without returning a value and without any arguments.
2.`display (x, y)`Calls the function without returning a value but with arguments `x` and `y`.

In simple words: To use a function, you "call" it by its name. The computer then checks if you gave it the right kind of information (arguments) by looking at its blueprint (prototype).

๐ŸŽฏ Exam Tip: Always make sure to define or declare a function (with its prototype) before calling it, otherwise the compiler won't know what to expect and will produce an error.

 

Question 3. Explain constant argument in detail.
Answer: A constant argument is a special type of parameter in a function that is declared using the `const` keyword. This keyword makes the variable's value stable, meaning it cannot be changed once it has been initialized. When you declare a constant variable, you must give it an initial value at the same time. The `const` modifier ensures that the value of the argument stays the same throughout the function's execution. It stops any accidental changes to the variable inside the function.
Syntax:
` (const )`
Example:
`int minimum(const int a=10);`
`float area(const float pi=3.14, int r=5);`
Program Example:
`#include `
`using namespace std;`
`double area(const double r,const double pi=3.14)`
`{`
`return(pi*r*r);`
`}`
`int main ()`
`{`
`double rad,res;`
`cout<<"AnEnter Radius :";`
`cin>>rad;`
`res=area(rad);`
`cout << "\nThe Area of Circle ="<`return 0;`
`}`
Output:
Enter Radius: 5
The Area of Circle =78.5
If the variable value โ€œrโ€ is changed as r=25; inside the body of the function "area" then compiler will throw an error as "assignment of read-only parameter 'r' โ€œ.
`double area (const double r, const double pi= 3.14)`
`{`
`r=25; // This line would cause an error.`
`return(pi*r*r);`
`}`
In simple words: A constant argument is a value given to a function that cannot be changed inside that function. It is marked with `const` to keep its value fixed.

๐ŸŽฏ Exam Tip: Using `const` for arguments ensures data integrity and allows the compiler to perform optimizations, making your code safer and potentially faster.

 

Question 4. Explain about address method.
Answer: When using the address method, the memory location (address) of the original value is copied to the function's parameter. This means if the function changes the parameter, the original value outside the function will also change. This is useful when you want a function to directly modify variables outside its own scope.
In simple words: This method shares the actual storage location of a variable with a function. So, if the function changes the variable, the change affects the original variable too.

๐ŸŽฏ Exam Tip: Remember that passing arguments by reference using the address method allows a function to modify the original variables, which is different from passing by value.

 

Question 5. Explain inline function in detail.
Answer: An inline function is a special type of function whose code is directly placed into the program where it is called, instead of calling it like a regular function. You add the 'inline' keyword in the function's header to make it inline. This process helps speed up the program by avoiding the usual function call steps. It also reduces overheads like managing the call stack for small functions. However, it can make the final program larger because the code is repeated at each call point.
Syntax:
inline return_type function_name (data_type parameter1, ...)
Advantages:
- Inline functions run faster because their code is directly inserted.
- They help to lower the complexity of using call stacks, especially for small functions.
In simple words: An inline function has its code copied directly to where it's used, making the program run faster. You use the 'inline' keyword for it. It's like putting the function's instructions right into your main code.

๐ŸŽฏ Exam Tip: Use inline functions for small, frequently called functions to optimize performance, but be aware that it might increase the overall program size.

 

Question 1. Program that reads two strings and appends the first string to the second. For example, If the first string Is entered as Tamil and the second string is Nadu, the program should print Tamilnadu. Use string library header.
Answer: This program reads two different sets of words (strings) from the user. Then, it joins the first set of words to the end of the second set, creating a single, longer set of words. For example, if you give "Tamil" and "Nadu", it will print "Tamilnadu". It uses functions from the string library to do this.
Program:
#include <string.h>
#include <iostream>
using namespace std;
int main()
{
char firststr[50],secondstr[50];
cout<<"\nEnter First String "; cin>>firststr;
cout<<"\nEnter Second String"; cin>>secondstr;
strcat(firststr,secondstr); //concatenation process
cout << "\nConcatenated string is : " <<firststr;
return 0;
}
Output:
Enter First String Tamil
Enter Second String nadu
Concatenated string is Tamilnadu
In simple words: The program takes two words from you, then glues the first word right after the second word and shows the combined result.

๐ŸŽฏ Exam Tip: Remember to include the <string.h> header for string manipulation functions like strcat().

 

Question 2. Program that reads a string and converts it to uppercase. Include required header files.
Answer: This program asks the user to type in a word or sentence (a string). After getting the input, it changes all the small letters in that word or sentence to capital letters. It uses functions from the string library to perform this conversion.
Program:
#include <string.h>
#include <iostream>
using namespace std;
int main()
{
char str[50];
cout<<"\nEnter a String\n";
cin>>str;
cout << "\nGiven string is : " << str;
strupr(str);
cout << "\nGiven string in Uppercase is :" << str;
return 0;
}
Output:
Enter a String
Computer
Given string is Computer
Given string in Uppercase is :COMPUTER
In simple words: You type a word, and the program turns all its small letters into big letters.

๐ŸŽฏ Exam Tip: For string conversion, remember to use functions from <string.h>. Ensure your program handles various characters correctly.

 

Question 3. Program that checks whether the given character is an alphabet or not. If It is an alphabet, whether It Is lowercase character or uppercase- character? Include required header files.
Answer: This program takes a single letter or character from the user. It then checks if the character is part of the alphabet. If it is an alphabet letter, the program further checks if it's a small letter (lowercase) or a capital letter (uppercase). It uses specific functions from the ctype header file for these checks.
Program:
#include <string.h>
#include <iostream>
#include <cctype>
using namespace std;
int main()
{
char ch;
cout<<"\nEnter a Character";
cin>>ch;
if(isalpha(ch))
{
if(islower(ch))
{
cout << "\nGiven Character is an Alphabet and in Lowercase";
}
else
{
cout << "\nGiven Character is an Alphabet and in Uppercase ";
}
}
else
{
cout << "\nGiven Character in not an Alphabet";
}
return 0;
}
Output:
Enter a Character:a
Given Character is an Alphabet and in Lowercase
Enter a Character:G
Given Character is an Alphabet and in Uppercase
Enter a Character:7
Given Character in not an Alphabet
In simple words: The program asks for a character. It checks if it's a letter, and if it is, it tells you if it's a small letter or a capital letter. If it's not a letter, it says so.

๐ŸŽฏ Exam Tip: Always remember to include the <cctype> header for character classification functions like isalpha() and islower().

 

Question 4. Program that checks whether the given character is alphanumeric or a digit Add appropriate header file
Answer: This program asks the user for a single character. It then checks if this character is alphanumeric (meaning it's either a letter or a number). If it's alphanumeric, it further checks if it's specifically a digit (a number from 0 to 9). This helps categorize characters quickly using isalnum() and isdigit() functions.
Program:
#include <string.h>
#include <iostream>
#include <cctype>
using namespace std;
int main()
{
char ch;
cout<<"\nEnter a Character";
cin>>ch;
if(isalnum(ch))
{
if(isdigit(ch))
{
cout << "\nGiven Character is an Alphanumeric and digit";
}
else
{
cout << "\nGiven Character is an Alphanumeric but not digit";
}
}
else
{
cout << "\nGiven Character in not an Alphanumeric or digit";
}
return 0;
}
Output:
Enter a Character: R
Given Character is an Alphanumeric but not digit
Enter a Character: 4
Given Character is an Alphanumeric and digit
Enter a Character: X
Given Character is an Alphanumeric but not digit
In simple words: The program takes a character and checks if it's a letter or a number. If it is, it then tells you if it's specifically a number.

๐ŸŽฏ Exam Tip: Remember to include the <cctype> header for `isalnum()` and `isdigit()` functions, which are crucial for character type checking.

 

Question 5. Write a function called zero_small () that has two integer arguments being passed by reference and sets smaller of the two numbers to 0. Write the main program to access this function.
Answer: This program defines a special function called `zero_small`. This function takes two whole numbers (integers) as input. Its job is to look at these two numbers and change the smaller one to zero. The numbers are passed "by reference," which means the original variables in the main part of the program will actually be changed by this function. The main program then uses this function and shows the numbers before and after the change.
Program:
using namespace std;
#include <iostream>
void zero_small(int &a, int &b)
{
if (a < b)
a = 0;
else
b = 0;
}
int main()
{
int num1, num2;
cout<<"\nEnter two numbers :"; cin>>num1>>num2;
cout<<"\nNumber before set small value as 0 through function : num1="
<<num1<<" num2="<<num2;
zero_small(num1,num2);
cout<<"\nNumber after set small value as 0 through function : num1="
<<num1<<" num2="<<num2;
return 0;
}
Output:
Enter two numbers: 12 11
Number before set small value as 0 through function : num1=12 num2=11
Number after set small value as 0 through function : num1=12 num2=0
Enter two numbers: 3 45
Number before set small value as 0 through function : num1=3 num2=45
Number after set small value as 0 through function : num1=0 num2=45
In simple words: The program has a function that takes two numbers. It finds the smaller number and makes it zero. Since it uses "pass by reference", the original numbers in the main program also change.

๐ŸŽฏ Exam Tip: When passing by reference (using `&`), changes made to the parameters inside the function will directly affect the original variables in the calling function. This is critical for functions designed to modify arguments.

 

Question 6. Write definition for a function sumseries () in C++ with two arguments/ parameters โ€“ double x and int n. The function should return a value of type double and it should perform sum of the following series: x-x2 /3! + x3 / 5! โ€“ x4 / 7! + x5 / 9! upto n terms.
Answer: This program defines a function called `sumseries` that calculates the sum of a special mathematical series. This function takes two inputs: a decimal number \( x \) and a whole number \( n \) (which tells how many terms of the series to add). The series follows a pattern of alternating positive and negative terms, where \( x \) is raised to increasing odd powers, and divided by factorials of increasing odd numbers. The function returns the total sum as a decimal number.
Program:
double sumseries(double x, int n)
{
double sum=0,t;
int f=1,sign=1;
t=x;
int i=1,j=1;
while(i<=n)
{
sum = sum + sign * t/f;
j=j + 2;
i++;
f = f*j*(j-1);
t = t * x;
sign = -sign;
}
return(sum);
}
int main()
{
double x_val;
int n_val;
cout<<"\nEnter X value ...";
cin>>x_val;
cout<<"\nEnter N value ...";
cin>>n_val;
cout<<"\nSUM OF THE SERIES = "<<sumseries(x_val,n_val);
return 0;
}
Output:
Enter X value ...5
Enter N value ...4
SUM OF THE SERIES = 7671
In simple words: This program calculates a sum based on a special math pattern using a given number (x) and how many steps (n) to use. It adds and subtracts terms that get more complex each time, like x minus x squared divided by 3 factorial, and so on.

๐ŸŽฏ Exam Tip: When calculating series, pay close attention to the factorial calculations, powers of x, and the alternating signs to avoid common errors.

 

Question 7. Program that Invokes a function calc () which intakes two integers and an arithmetic operator and prints the corresponding result.
Answer: This program defines a function called `calc` that performs basic math operations like addition, subtraction, multiplication, and division. The `calc` function takes two whole numbers and a character representing the math operator (like `+`, `-`, `*`, or `/`). It then calculates the result based on the operator and prints it. The main part of the program asks the user for two numbers and an operator, then calls `calc` to show the answer.
Program:
#include <iostream>
using namespace std;
void calc(int num1,int num2,char op)
{
int result;
switch(op)
{
case'+':
result = num1 + num2;
cout<<"\nAdded value "<<result;
break;
case'-':
result = num1 - num2;
cout<<"\nSubtracted value "<< result;
break;
case'*':
result = num1 * num2;
cout<<"\nMultiplied value"<<result;
break;
case '/':
if (num2 != 0) {
result = num1 / num2;
cout<<"\nDivided value "<<result;
} else {
cout<<"\nError: Cannot divide by zero.";
}
break;
default:
cout<<"\nPROCESS COMPLETED - Invalid Operator";
break;
}
}
int main()
{
int n1, n2;
char op;
cout<<"\nEnter two numbers: "; cin>>n1>>n2;
cout<<"\nEnter an Operator + or โ€“ or * Or / :"; cin>>op;
calc(n1,n2,op);
return 0;
}
Output:
Enter two numbers:10 20
Enter an Operator + or - or * Or / :+
Added value 30
Enter two numbers:10 20
Enter an Operator + or - or * Or / :-
Subtracted value -10
Enter two numbers:10 20
Enter an Operator + or - or * Or / :*
Multiplied value 200
Enter two numbers:20 10
Enter an Operator + or - or * Or / :/
Divided value 2
In simple words: This program uses a function to do simple math. You give it two numbers and a math sign (like +, -, *, /), and it will show you the answer after doing that calculation.

๐ŸŽฏ Exam Tip: When creating a calculator function, always include a `default` case in your `switch` statement to handle invalid operator inputs gracefully, and add a check for division by zero to prevent program crashes.

(The provided OCR for pages 85-87 contains only image outputs, branding, metadata, and navigation links. There are no questions (e.g., "Question 1.") or educational content suitable for conversion within the specified page range.)

TN Board Solutions Class 11 Computer Science Chapter 11 Functions

Students can now access the TN Board Solutions for Chapter 11 Functions prepared by teachers on our website. These solutions cover all questions in exercise in your Class 11 Computer Science textbook. Each answer is updated based on the current academic session as per the latest TN Board syllabus.

Detailed Explanations for Chapter 11 Functions

Our expert teachers have provided step-by-step explanations for all the difficult questions in the Class 11 Computer Science chapter. Along with the final answers, we have also explained the concept behind it to help you build stronger understanding of each topic. This will be really helpful for Class 11 students who want to understand both theoretical and practical questions. By studying these TN Board Questions and Answers your basic concepts will improve a lot.

Benefits of using Computer Science Class 11 Solved Papers

Using our Computer Science solutions regularly students will be able to improve their logical thinking and problem-solving speed. These Class 11 solutions are a guide for self-study and homework assistance. Along with the chapter-wise solutions, you should also refer to our Revision Notes and Sample Papers for Chapter 11 Functions to get a complete preparation experience.

FAQs

Where can I find the latest Samacheer Kalvi Class 11 Computer Science Solutions Chapter 11 Functions for the 2026-27 session?

The complete and updated Samacheer Kalvi Class 11 Computer Science Solutions Chapter 11 Functions is available for free on StudiesToday.com. These solutions for Class 11 Computer Science are as per latest TN Board curriculum.

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

Yes, our experts have revised the Samacheer Kalvi Class 11 Computer Science Solutions Chapter 11 Functions 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 TN Board solutions help in scoring 90% plus marks?

Toppers recommend using TN Board language because TN Board marking schemes are strictly based on textbook definitions. Our Samacheer Kalvi Class 11 Computer Science Solutions Chapter 11 Functions will help students to get full marks in the theory paper.

Do you offer Samacheer Kalvi Class 11 Computer Science Solutions Chapter 11 Functions in multiple languages like Hindi and English?

Yes, we provide bilingual support for Class 11 Computer Science. You can access Samacheer Kalvi Class 11 Computer Science Solutions Chapter 11 Functions in both English and Hindi medium.

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

Yes, you can download the entire Samacheer Kalvi Class 11 Computer Science Solutions Chapter 11 Functions in printable PDF format for offline study on any device.