A. Computational function.
B. Manipulative Functions.
C. Procedural Functions.
D. none of the above.
The function that perform an action and have no explicit return value is called a procedural function.
A. one way.
B. two ways.
C. three ways.
D. four ways.
A function can be invoked in two ways i.e. either by call by value or by call by reference method.
A. only by value.
B. only by reference.
C. by value as well as by reference.
D. default.
Function call need not be purely by value, or by reference. Mix of the two is also possible.
A. variables.
B. constants.
C. expressions.
D. all of the above.
Only variables can be passed by reference, not the constants or expressions.
A. the called function can access and works with the original values using their references.
B. changes made are not reflected back to original value.
C. values of variable is passed.
D. all of the above.
In call by reference method a reference to the original variable is passed and the called function can access and works with the original values using their references.
A. -32768 to 32767
B. 0 to 65,535
C. -128 to 127
D. 0 to 255
The unsigned short int type can be used for variables which will have only positive and zero whole number values, within the range of the unsigned short type. It ranges from 0 to 65,535.
A. under this, the changes are not reflected back to the original values.
B. function creates its own copy and uses the values.
C. the values of actual parameters into formal parameters.
D. all of the above.
What happens inside the function has no effect on the variables used in function call.
A. error occurs.
B. 0 is not returned.
C. calculated value is returned.
D. no value is returned.
A return statement is used to terminate a function whether or not it returns a value.
A. variables.
B. constant arguments.
C. variables with strings.
D. none of the above.
By constant argument, it is meant that there values can not be modified. That is why function cannot modify these arguments.
A. default arguments cannot be used.
B. default arguments can be used.
C. the value has to be entered each time.
D. none of the above.
Default arguments are useful in situations where some arguments always have the same value.
A. when its matching value is missing in the function statement.
B. in a program when matching value is given.
C. by the program when it is not required.
D. none of these.
C++ allows us to assign default values to a function parameters which is useful in case a matching argument is not passed in the function call statements.
A. Valid. Syntax correct.
B. Invalid argument, syntax error as variables not declared.
C. Invalid as length value should not be given.
D. None of the above.
correct syntax is
int area(int length=3,int breadth=1);
A. passed in the function call statement.
B. not passed in the function call statement.
C. may or may not be passed in the calling statement.
D. none of the above.
Default values of parameter are specified at the time of function declaration, not at function call statement.
The functions in the header file iostream.h are: seekg(), put(), write(), seekp(), open(), close(), flush(), clear().
The C standard library consists of a set of sections of the ANSI C standard which describes collections of headers and library routines, whereas C++ library consists of a collection of functions, constants, objects and templates.
Two functions of header file stdlib.h are:
1. malloc:
2. free:
The output of the program is 16.
It is calculating the square of 4 or the value of (4)2.
String is treated by c++ as an array which is terminated by null character ‘0;
The prototype required for this is string.h as the header file.
i. isalnum() function is a character function and it checks whether its argument is alpahnumeric or not.
ii. isalpha() function isa character function and it checks whether its argument is alphabetic or not.
The strcmp( ) function compares two strings. It returns less than zero value to the string which is shorter. It returns zero, if two strings are equal.
islower(c) means c is a lowercase character.
tolower( ) converts uppercase(C) character tolower case(c).
The inbuilt functions belong to the following header files:
i) eof belongs to the header file iostream.h.
ii) puts belongs to the header file stdio.h.
iii) strcmp belongs to the header file string.h.
iv) get belongs to header file iostream.h.
The two functions used to convert between letter cases are:
1.
2. toupper: Converts lowercase letter to uppercase.

A program in C++ to check the size of the string:
#include< iostream.h >
#include< conio.h >
#include< string.h >
int main()
{
char str1[100];
cout < < "enter a string: ";
cin > > str1;
cout < < " The size of str1 is " < < strlen(str1) < < " characters";
getch();
return 0;
}


3. stderr: It is a standard error stream. It is an output stream used specifically to find out the errors.


The required header files are:
string.h for strlen()
stdio.h for puts()
Mathematical functions help in mathematical calculations. The header file used for these functions is math.h. These functions performs mathmetical calculations and conversions.
Some of the mathmetical functions are sqrt(), log(), pow(), sin() etc.
The C++ language contains some statements only and not any built-in functions. A library is a collection of subprograms used to develop other programs and software. Libraries are not independent programs but act as helper codes used in other independent programs. The C++ library of functions stores functions of same category (e.g., mathematical functions, string functions etc.) under separate files known as header files.
|
Function |
Description |
|
isalpha |
Tests for alphabetic characters |
|
isalnum |
Tests for alphanumeric characters |
|
islower |
Tests for lowercase letter |
|
isupper |
Tests for uppercase letter |
|
tolower |
Converts character to lowercase |
|
toupper |
Converts character to uppercase |
A. make a variable visible to several functions.
B. make a variable visible to only one function.
C. conserve memory when a function is not executing.
D. retain a value when a function is not executing.
A special type of local variable, called a static local, is available in many mainstream languages, including C/C++, Visual Basic and VB.NET, which allows a value to be retained from one call of the function to another.
A. it returns a rvalue.
B. it returns a lvalue.
C. it returns a rlvalue.
D. it returns a lrvalue.
The left-hand side of an assignment statement must consist only of a single, previously declared, variable. The left-hand side of an assignment is called the target -- the variable whose contents are changed as a result of the assignment.
A. life scope of the variable.
B. active period of the variable.
C. lifetime of the variable.
D. timer of the variable.
A variable's lifetime is its parent-block-run, i.e., as long as its parent block is executing, the variable lives in the memory.
A. closed function.
B. information hiding.
C. unclear function.
D. function encapsulation.
Information hiding in computer science is the principle of hiding of design decisions in a computer program, that are most likely to change. Thus, protecting other parts of the program from change, if the design decision is changed.
A. the changes occurring during the called function’s execution are not to be reflected back to the original variables.
B. the default argument value is missing its function call.
C. the entire function call can be assigned to a variable.
D. the function returns a value.
The main benefit of call by value method is, that we cannot alter the variables that are used to call the function, because any changes that occurs inside function is on the function’s copy of the argument value.
A. a variable is created in the function to hold the argument’s value.
B. the function cannot access the argument’s value.
C. a temporary variable is created in the calling program to hold the argument’s value.
D. the function accesses the argument’s original value in the calling program.
In call by reference method, a reference to the original variable is passed. A reference is an alias for a predefined variable.
A. a static variable has a function scope but the static function has a program scope.
B. a static variable has a file scope but the static function has a program scope.
C. a static variable has a function scope but the static function has a file scope.
D. a static variable has a file scope but the static function has a function scope.
A static function is a function whose scope is limited to the current source file. A static function has a file scope instead of program scope.
A. increase complexity.
B. increase ambiguity.
C. increase program size.
D. reduce program size.
Functions make program handling easier, as only a part of the program to deal with.
A. global.
B. external.
C. static.
D. auto.
The auto storage-class specifier declares an automatic variable, a variable with a local lifetime. It is the default storage-class specifier for variables.
A. cannot be passed as arguments.
B. can be passed as arguments.
C. can not be passed.
D. none of the above.
When a variable is passed by reference we are not passing a copy of its value, but we are somehow passing the variable itself to the function and any modification that we do to the local variables will have an effect in their counterpart variables passed as arguments in the call to the function.
A. constant.
B. variable.
C. reference variable.
D. constant variable.
A reference is an alternative name for an object. A reference variable provide an alias for a previously defined variable.
A. call by reference.
B. call by value.
C. changing parameter.
D. changing argument.
In call by reference method, a reference to the original variable is passed and changes made in these variable reflected back to the memory address. thus permanent change in memory address is done.
A. extern.
B. static.
C. register.
D. auto.
External variables are globally accessible. They remains in existence permanently as they retain their values even after the functions that set them was returned. i.e. why these variables specifies that they are already been defined in the program.
A. local scope.
B. function scope.
C. class scope.
D. file scope.
The variables declared and used in the function have function scope.
A. static.
B. extern.
C. register.
D. auto.
The C++ register keyword can be used as a hint to the compiler that the declared variable is to be accessed very often during program execution, and hence, require faster access.
A. extern.
B. static.
C. register.
D. auto.
The auto storage-class specifier declares an automatic variable, a variable with a local lifetime. It is the default storage-class specifier for variables.
A. local.
B. function.
C. file and class.
D. all of the above
There are four kinds of scope in C++: local, function, file and class.
A. exit( ).
B. return.
C. stop.
D. end.
A. one type.
B. Two types.
C. Three types.
D. four types.
There may be three types of functions in c++:
(1) Computational functions.
(2) Manipulative functions.
(3) Procedural functions.
A. passed as value generally.
B. passed as reference.
C. cannot be passed.
D. none of the above.
you must pass arrays by reference; you'll get a syntax error if you try to pass an array by value. Because arrays are passed by reference, you can pass an array to another procedure to be modified, and then continue working with the modified array in the calling procedure.
The following header files are used in C++ language:
4. stdlib.h: This header file declares several commonly used routines like conversion routines, search/sort routines and other miscellaneous things.
The functions which are used to generate random numbers are as follows:
1.
2.
3.
4.
5.
• rand(): The rand function returns a “random” positive integer from 0 to a large value (atleast 32767) everytime it is called. To scale the value into the range, use the mod (%) operator and addition.
• rand_max(): Value of rand_max() varies between compilers and
can be as low as 32767 which would give a range from 0 to 32767 for
rand().
• random(): random(num) generates a random number within 0 to
num-1, For example, random(10) will generate random numbers from
0 to 9.
• randomize(): initializes / seeds the random number generator with a
random number.
• srand(): srand() is used to prevent the repetition of random numbers whenever the program is executed.
stdlib.h is the header file that declares several commonly used routines like conversion routines, search and sort routines etc.
Some of the functions of stdio.h are _fullpath, _makepath, _search.h, _splitpath.
fullpath: function formulates the full pathname for a file from its relative path relPath argument and stores the result in absPath, returning a pointer to the resulting string.
makeapath: builds a path from components path.
search.h: Some search types are-
bsearch performs a binary search.
lsearch performs a linear search
searchenv searches on environment path for a file.
splitpath: splits a full path into its components.
A. constant.
B. variable.
C. reference variable.
D. constant variable.
A reference is an alternative name for an object.
A. prototype declaration has no body.
B. prototype declaration cannot access the argument’s value.
C. prototype declaration is optional to gives function prototype.
D. prototype declaration has its code.
The prototype declaration looks just like a function definition except that it has no body.
A. to reduce the program size.
B. non-readable to the user.
C. to increase ambiguity.
D. a complex program handling.
Use of function avoids ambiguity. It reduces the program size and thus, makes the program more readable and understandable to the programmer.
A. online function.
B. inclined function.
C. inline function.
D. outline function.
An inline function is that, which is not involved at the time of function call, rather its code replaces the function call that invokes it, in the program. Thus, inline functions save the overhead of a function call.
A. its corresponding value is missing in its function call.
B. the variable name in the function prototype is specified.
C. the function accesses the argument’s original value in the calling program.
D. a temporary variable is created in the calling program to hold the argument’s value.
For some functions, one may want to make some of its parameters as optional and use the default values, if the user does not want to provide values for such parameters. This is done with the help of default argument values.
A. referenced variable.
B. static variable.
C. private variable.
D. protected variable.
A static variable, also referred to as a class variable is a variable, which exists across an instance of a class.
A. program prototype
B. program declaration.
C. variable’s scope.
D. variable declaration.
The scope decides, in which part of the program a particular piece of code would be known and can be accessed .
A. function argument.
B. function documentation.
C. function definition.
D. function prototype.
The general form of a function definition is given by type function-name(parameter list)
{
Body of the function
}
A. function.
B. prototype.
C. document.
D. argument.
A function prototype is a declaration of a function, that tells the program about the type of the value returned by the function and the number and type of arguments received by it.
A. function.
B. prototype.
C. document.
D. argument.
A function is a subprogram that acts on the data and often returns a value.
A. program scope.
B. file scope.
C. function scope.
D. loop scope.
A static function is a function whose scope is limited to the current source file. A static function has a file scope instead of a program scope.
A. function space.
B. function declarator.
C. function initiator.
D. function definition.
A function declarator is the function name followed by a parenthesized list of parameter types and names of each parameter that the function expects.
A. global variable.
B. local variable.
C. register variable.
D. static variable.
Register variables are a special case of automatic variables. Automatic variables are allocated storage in the memory of the computer; however, for most computers, accessing data in memory is considerably slower than processing in the CPU.
A. computational functions.
B. manipulative functions.
C. procedural functions.
D. declarative functions.
The functions that compute some value and return the calculated value, are known as computational functions. For example, sqrt( ) and cos( ).
A. computational functions.
B. manipulative functions.
C. procedural functions.
D. declarative functions.
Manipulative functions are the functions that manipulate the information and return a success or failure code. If 0 is returned, it denotes a successful operation and if any other number is returned, it denotes a failure.
A. computational functions.
B. manipulative functions.
C. procedural functions.
D. declarative functions.
When the function performs some action and has no return type, is known as a procedural function. For example: exit( ) function.
A. two.
B. three.
C. four.
D. five.
The three types of functions in C++ are: computational functions, manipulative functions and procedural functions.
A. function declaration, function definition and function prototype.
B. function declaration, function definition and function call.
C. function declaration, function creation and function prototype.
D. function declaration, function deletion and function prototype.
Function declaration is required to specify the function's interface to a program. Function definition is required to tell the program about what and how a function is doing. Function call is required to invoke the function.
A. two.
B. three.
C. four.
D. five.
The two ways are: using a reference parameter and using a value returning function with an assignment statement.
A. folder.
B. global.
C. object.
D. class.
The name of a class member has a class scope and is local to its class.
A. two.
B. three.
C. four.
D. five.
C++ provides four kinds of scope: local, function, file and class.
A. scope.
B. function.
C. reference.
D. prototype.
A reference is an alias or an alternative name for an object. All the operations applied to a reference act on the object to which the reference refers.
A. global variable.
B. local variable.
C. reference variable.
D. variable's scope.
In computer science, a local variable is a variable that is given local scope. Such a variable is accessible only from the function or block in which it is declared.
A. global variable.
B. local variable.
C. reference variable.
D. variable’s scope.
In computer programming, a global variable is a variable that is accessible in every scope.
A. actual parameters.
B. formal parameters.
C. functional parameters.
D. global parameters.
Formal parameters are the variables declared in the parameter list of a subprogram (such as a procedure or a function)specification.
A. parameters.
B. arguments.
C. formal parameters.
D. function call.
Actual parameters are the variables or expressions referenced in the parameter list of a subprogram call. They are also known as arguments.
A. constant.
B. variable.
C. entity.
D. register.
All the functions except those of type void, return a value. The return statement explicitly specifies this value. When a value is returned, the entire function can be assigned to a variable.
A. invoked at the time of function call.
B. not invoked at the time of function call.
C. modified by the function.
D. declared with an empty argument list.
An inline function is that which is not invoked at the time of function call rather its code replaces the very function call that invokes it, in the program.
A. function pass actual parameters.
B. function pass formal parameters.
C. function pass informal parameters.
D. function does not pass parameters.
A function declared with an empty argument list as void display(); means that the function does not pass any parameters. It is identical to the statement void display(void);
A. program-run.
B. function-run.
C. block-run.
D. scope-run.
A variabless lifetime is its parent-block-run. Therefore, the lifetime of local variables having function scope is the function-run.
A. program-run.
B. function-run.
C. block-run.
D. scope-run.
A variable's lifetime is its parent-block-run. The global variable's lifetime is the program-run, i.e., the time during which the program executes.
A. file scope operator.
B. function scope operator.
C. scope resolution operator.
D. block resolution operator.
To differentiate from the normal functions with the member functions of the class, one needs to use the scope resolution operator (::) in between the class name and the member function name i.e. ship::foo() where the ship is the class and the foo() is the member function in the ship.
A. file scope operator.
B. function scope operator.
C. scope resolution operator.
D. block resolution operator.
The scope resolution operator (::) in C++ is used to define the already declared member functions (in the header file with the .hpp extension) of the class.
A. program-run.
B. function-run.
C. block-run.
D. scope-run.
A variable's lifetime is its parent-block-run. Therefore, the lifetime of local variables having block scope is the block-run.
A. function documentation.
B. function argument.
C. function declaration.
D. function reference.
A function prototype is a declaration of a function, that tells the program about the type of the value returned by the function and the number and type of arguments received by it.
A. break statement.
B. reverse statement.
C. return statement.
D. default statement.
In computer programming, a return statement causes execution to leave the current subroutine and resume at a point in the code immediately after, where the subroutine was called - known as its return address.
A. one.
B. two.
C. zero.
D. infinite.
All functions except those of the type void return a value. The return statement explicitly specifies this value.
A. to reside.
B. to print.
C. to manipulate.
D. either of the above
Return value can be used for different purposed such as to reside, manipulate or to print.
A. can be used in expressions.
B. none of these.
C. cannot be used in expressions.
D. cannot be used in calculations.
Expressions generally use the functions that have returning value.
A. function prototyping.
B. function definition.
C. function calling.
D. all of the above.
Functions are made up of three parts
(1) Function Declaration.
(2) Function Definition.
(3) Function calling.
A. Parentheses.
B. Braces.
C. Quotation marks.
D. Any of the above.
Parameter that we pass in function is enclosed in parenthesis'(' ')'
for example: int func(int a, int b)
{
}
a and b are parameters.
A. Parenthesis ( )
B. Semicolon ( ; )
C. Braces { }
D. Quotes
Eg:-
Both the above statements ends with semicolon.
A. one type.
B. two type.
C. three type.
D. four type.
Function can be of three types:
(1) Computational Functions
(2) Manipulative Functions
(3) Procedural Functions
A. all four.
B. only two.
C. only one.
D. only three.