CBSE - MCQ Question Banks (के. मा. शि. बो . -प्रश्नमाला )

PreviousNext

Q. 193201 In function prototyping names of..


A. function declaration cannot be skip argument names.

B. arguments are optional.

C. giving argument name is essential.

D. none of the above.

Right Answer is: B

SOLUTION

Function declaration can skip the argument names as they are optional in a function.


Q. 193202 The place of declaration of function or variable


A. determines its scope.

B. determines the way it is initialized.

C. determines its length.

D. determines its definition.

Right Answer is: A

SOLUTION

The place of declaration of function or variable determines the scope of that function and variable.


Q. 193203 data type specifies empty set of values


A. void.

B. int.

C. float.

D. none of them.

Right Answer is: A

SOLUTION

void datatype specifies an empty set of values and it is used as the return type for functions that do not return a value.


Q. 193204 A Function definition...


A. may be without parameter list.

B. must have a parameter list.

C. must not have a parameter list.

D. none of these.

Right Answer is: A

SOLUTION

A function may be without any parameters, in which case, the parameter list is empty.


Q. 193205 Function definition does...


A. end with comma.

B. end with quotes.

C. end with a semicolon.

D. not end with semicolon.

Right Answer is: D

SOLUTION

The general form of function definition is: type function_name(parameter list)
{
body of function
}

There is no semicolon in function definition.  


Q. 193206 parameter also refered as


A. variables.

B. values.

C. arguments.

D. data.

Right Answer is: C

SOLUTION

The parameter list is a comma separated list of variables of a function referred to as its arguments.


Q. 193207 If type specifier is omitted in function declaration...


A. it is returning float value.

B. it is returning char value.

C. it is returning int value.

D. no type is being returned.

Right Answer is: C

SOLUTION

If no type is specified in a function , the compiler assumes that the function returns an integer value.


Q. 193208 Parameter list of the function definition is also referred to as its...


A. arguments.

B. variables.

C. constants.

D. tokens.

Right Answer is: A

SOLUTION

parameter list is also referred to as Arguments. 


Q. 193209 In type function name(void)...


A. parameter list is empty.

B. argument list is not void.

C. type is empty.

D. type of data is to be given.

Right Answer is: A

SOLUTION

void data type specifies an empty set of values i.e. why in above function parameter list is empty.


Q. 193210 If type is not specified, the computer assumes that the function returns...


A. Float value.

B. Integer value.

C. Char value.

D. Exial unit.

Right Answer is: B

SOLUTION

If no type is specified in a function , the compiler assumes that the function returns an integer value.


Q. 193211  Function declaration float size(float,float) is...


A.  valid as argument names can be skipped.

B.  invalid as argument names cannot be skipped.

C.  may not be skipped.

D.  none of these.

Right Answer is: A

SOLUTION

In function declaration, the names of the arguments are optional therefore they can be omitted.


Q. 193212 Under function definition, type can be..


A. Integer.

B. Character.

C. Float.

D. Any valid c++ data type.

Right Answer is: D

SOLUTION

Type specifies the type of value that the return statement of the function returns. It may be any valid C++ data type.


Q. 193213 The functions created by a programmer is called as:


A. Library functions.

B. User defined functions.

C. Built-in functions.

D. none of them.

Right Answer is: B

SOLUTION

User defined functions are the functions created by a programmer.


Q. 193214 exit( ), sqrt( ), pow( ) are examples of


A. user-defined functions.

B. built-in functions.

C. local functions.

D. classes.

Right Answer is: B

SOLUTION

These functions are part of standard library, which are made available by the compiler. Hence, these are library or built-in functions.


Q. 193215 A Function definition


A. may be without parameter list.

B. must have a parameter list.

C. must not have a parameter list.

D. gives compiler error, if parameters are used.

Right Answer is: A

SOLUTION

The syntax of function definition is: type function-name (parameter list) { body of the function }


Q. 193216 If type specifier is omitted in function declaration


A. it is returning float value.

B. it is returning char value.

C. it is returning int value.

D. no type is being returned.

Right Answer is: C

SOLUTION

By default, the compiler returns an int value if no type is specified.


Q. 193217 There must be a return statement in a


A. function definition.

B. function declaration.

C. function call.

D. function prototype.

Right Answer is: A

SOLUTION

The syntax of a function definition is: type function-name(parameter list) { body of the function } Here, type specifies the type of value that the return statement of the function returns.


Q. 193218 If type is not specified, the computer assumes that the function returns a/an


A. float value.

B. integer value.

C. char value.

D. exial unit.

Right Answer is: B

SOLUTION

By default, the computer takes an integer value.


Q. 193219 Default value of an argument is used in a program, when


A. its matching value is missing in the function call statement.

B. matching value is given in the function call statement.

C. its matching value is missing in the function definition statement.

D. there is a compiler error.

Right Answer is: A

SOLUTION

Default values are specified at the time of function declaration, when there is no matching arguments in the function call.


Q. 193220 The other name for built-in functions is


A. user-defined functions.

B. programmer's functions.

C. compiler functions.

D. library functions.

Right Answer is: D

SOLUTION

These functions are a part of compiler package. They are a part of standard library, made available by the compiler.


Q. 193221 Default values to parameter list are


A. passed in the function call statement.

B. not passed in the function call statement.

C. passed in the function definition.

D. not passed in the function declaration.

Right Answer is: B

SOLUTION

Default values are passed in the function prototype. It is useful in case a matching argument is not passed in the function call statement.


Q. 193222 The functions created by programmer are called


A. built-in functions.

B. user-defined functions.

C. library functions.

D. function statistics.

Right Answer is: B

SOLUTION

These functions are created by the user as per requirements of a program.


Q. 193223 If a function declaration is : type function-name(void); then it means that


A. parameter list is empty.

B. argument list is not void.

C. type is empty.

D. type of data is to be given.

Right Answer is: A

SOLUTION

Specifying void in the function prototype, means that function takes no arguments.


Q. 193224 Specifying the function's interface to the program is called


A. function declaration.

B. function definition.

C. function calling.

D. function manipulation.

Right Answer is: A

SOLUTION

A function declaration tells the program about the type of the value returned by the function and the number and type of arguments.


Q. 193225 Parameters are enclosed in


A. parentheses.

B. braces.

C. quotation marks.

D. hypens.

Right Answer is: A

SOLUTION

parentheses ( ) are used to enclose the parameters or arguments.


Q. 193226 In defining function, type specifies...


A. the type of function used.

B. the type of parameters.

C. the type of value returned by the return statement of the function.

D. none of these.

Right Answer is: C

SOLUTION

Type specifies the type of value that the return statement of the function returns. It may be any valid C++ data type.


Q. 193227  Built in functions and User defined functions are...?


A. built by the programmer.  

B. 2 Types of functions.  

C. built by the program.  

D. none of these.  

Right Answer is: B

SOLUTION

 Function are of two types:

. Built in functions are a part of the standard library made available by the compiler.
. And user defined function are created by the programmer.  


Q. 193228  After the execution of the function...


A.  Control is transferred back to the calling code.

B.  Stays with the function.

C.  Program ends.

D.  Output is displayed.

Right Answer is: A

SOLUTION

 Calling code refers to the code which has called the function.


Q. 193229 default values are specified at the time of


A. Functions definition.

B.  Function declaration.

C.  Function calling.

D.  Function returning.

Right Answer is: B

SOLUTION

The default values are specified at the time of function declarartion.

for example:     int add(int a = 2, int b = 3);


Q. 193230 Default value of an argument is used in a program, when


A. its matching value is missing in the function call statement.

B. matching value is given in the function call statement.

C. its matching value is missing in the function definition statement.

D. there is a compiler error.

Right Answer is: A

SOLUTION

Default values are specified at the time of function declaration, when there is no matching arguments in the function call.


Q. 193231 Auto variable with faster access is


A. static.

B. extern.

C. register.

D. static.

Right Answer is: C

SOLUTION

It provides faster access,as variables are stored in CPU registers rather than in memory.


Q. 193232 Array name is


A. a pointer to any element of the array.

B. a pointer to the first element.

C. not a pointer to the array.

D. not a pointer to the first element.

Right Answer is: B

SOLUTION

Array name always points to the first element of an array.


Q. 193233 The range of unsigned short integer is


A. -32768 to 32767

B. 0 to 65,535

C. -128 to 127

D. 0 to 255

Right Answer is: B

SOLUTION

A short integer is a data type that can represent a whole number which may take less storage, while having a smaller range, compared with a standard integer on the same machine. An unsigned short integer is either positive or zero and ranges from 0 to 65,535.


Q. 193234 The names of the arguments are optional in


A. function definition.

B. function declaration.

C. function statistics.

D. function manipulation.

Right Answer is: B

SOLUTION

Example: int volume(int x, int y, int z); int volume(int, int, int); Both are correct. A function declaration can skip the argument names, but a function definition cannot.


Q. 193235 The data type which specifies an empty set of values, is


A. char.

B. float.

C. int.

D. void.

Right Answer is: D

SOLUTION

It is used as the return type for functions that do not return a value.


Q. 193236 A function can not modify


A. variables.

B. constant arguments.

C. variables with strings.

D. arrays.

Right Answer is: B

SOLUTION

Constants have fixed values, their values can not be changed during a program run.


Q. 193237 Parameter list of the function definition is also referred to as its


A. arguments.

B. variables.

C. constants.

D. tokens.

Right Answer is: A

SOLUTION

Example: int sum( int a, int b) { } Here a, and b are arguments.


Q. 193238 The number of fundamental data types available are


A. two.

B. three.

C. four.

D. five.

Right Answer is: D

SOLUTION

There are 5 fundamental data types. These are: int, char, float, double and void.


Q. 193239  Function must be defined...


A.  anywhere in the program.

B.  at the end of the subprogram.

C.  before using it anywhere in the program.

D.  none of these.

Right Answer is: C

SOLUTION

In C++, a function must be defined before it is used anywhere in the program.


Q. 193240 In defining function, type specifies


A. the type of function used.

B. the type of parameters.

C. the type of value returned by the return statement of the function.

D. the type of functional call.

Right Answer is: C

SOLUTION

The function prototype and the function definition must have same return type, function name, and argument/parameter list.


Q. 193241 The place of declaration of function or variable


A. determines its scope.

B. determines the way it is initialized.

C. determines its length.

D. determines its definition.

Right Answer is: A

SOLUTION

Scope determines the lifetime of a variable.


Q. 193242 Function returning a reference


A. can appear on the left hand side of an expression.

B. can appear on the right hand side of an expression.

C. depends on the condition being met.

D. gives run time error.

Right Answer is: A

SOLUTION

A function returning reference can appear on the left hand side of an assignment statement. Example: let say min( )is a function, and a call to min(x, y)returns a reference to a or b. Here, min(x,y)=-7 is perfectly all right.


Q. 193243 Description of what the function is doing, and how it is doing is done using


A. function declaration.

B. function definition.

C. function prototyping.

D. function call.

Right Answer is: B

SOLUTION

Function definition tells program about the type of the value returned by the function, and the number and type of arguments.


Q. 193244 Under function definition, the type specifier can be


A. only integer.

B. only character.

C. only float.

D. any valid c++ data type.

Right Answer is: D

SOLUTION

By default, the computer assumes an integer value, and for the functions returning non-integer values, the type specifier must be given.


Q. 193245 Function call can be made using


A. call by value only.

B. call by reference only.

C. call by value as well as call by reference.

D. default value.

Right Answer is: C

SOLUTION

Function call need not be purely by value, or reference. Mix of the two is also possible.


Q. 193246 C++ makes the function prototyping


A. optional.

B. essential.

C. illegal.

D. not necessary.

Right Answer is: B

SOLUTION

Function prototyping is must in a C++ program. The syntax of function prototyping is: type function-name (parameter list);


Q. 193247 All variables by default are


A. global.

B. external.

C. static.

D. auto.

Right Answer is: D

SOLUTION

The auto storage-class specifier declares an automatic variable, a variable with a local lifetime.


Q. 193248 By default, all local variables are


A. extern.

B. static.

C. register.

D. auto.

Right Answer is: D

SOLUTION

auto storage-class specifier declares an automatic variable, a variable with a local lifetime.


Q. 193249 Memory location that is shared by two or more different variables is


A. structure.

B. class.

C. union.

D. reference.

Right Answer is: C

SOLUTION

Unions allow same portion of memory to be accessed as different data types, since all of them are in fact the same location in memory. The keyword union is used for declaring and creating a union.


Q. 193250 Variables that are not initialised are


A. empty.

B. null.

C. not empty.

D. illegal.

Right Answer is: C

SOLUTION

Variables that are not initialized contain garbage values left over from the program that last used the memory.


Q. 193251 65L is a/an


A. long integer constant.

B. integer constant.

C. char constant.

D. pointer constant.

Right Answer is: A

SOLUTION

L suffix indicates it is long integer constant.Example: 25 is an integer constant, whereas 25L is a long integer constant.


Q. 193252 The variables declared in the function scope


A. can be acessed inside a block.

B. can be accessed from any function.

C. can be accessed only from the function that declares them.

D. can be accessed inside any class.

Right Answer is: C

SOLUTION

The variables declared in the outermost block of a function have function scope.


Q. 193253 To terminate a function, we use


A. exit( ).

B. return.

C. stop.

D. end.

Right Answer is: B

SOLUTION

The return has two functions: 1. Causes immediate exit from the function and return control to the operating system. 2. Used to return a value to the calling code.


Q. 193254 TThe invalid structure name is


A. Student;.

B. Employee;.

C. 1student;.

D. _student;.

Right Answer is: C

SOLUTION

The name of a structure follows the simple rules for a variable name. So a structure name cannot start with a  digit.


Q. 193255 Each instance of a structure is called the


A. member.

B. variable.

C. component.

D. tag.

Right Answer is: B

SOLUTION

Each instance of a structure, which is declared by the struct_name var_name; statement is called the structure variable.


Q. 193256 A structure being passed to a function, can be passed by


A. call by reference.

B. call by value result.

C. call by reference and call by value.

D. call by value result.

Right Answer is: C

SOLUTION

A structure variable can be passed by value as well as by reference.


Q. 193257 In C++ "- >" is also known as


A. pointer operator.

B. address of operator.

C. reference operator.

D. member access operator.

Right Answer is: D

SOLUTION

- > is the member access operator to access the pointers being declared, inside a structure.


Q. 193258 A structure is sometimes known as


A. class.

B. conglomerate data type.

C. public class.

D. default class.

Right Answer is: B

SOLUTION

It is called as such, because it is a group of several variables under one roof.


Q. 193259 The statement to access an element in structure b is


A. b > var.

B. b- > var.

C. b.var.

D. var.b.

Right Answer is: C

SOLUTION

To access a variable of a structure the ‘.’ operator is used in the format; Structure_name.Variable_name


Q. 193260 The invalid statement among the given statements is


A. if( struct s1==struct s2)

B. struct s1{};

C. s2=s1; where both s2 and s1 belong to same data type.

D. addr address; where addr is a structure already defined.

Right Answer is: A

SOLUTION

We can not compare two structures.


Q. 193261 When reference to a structure is passed to a function,


A. any change made is only temporary.

B. changes are made in the original values of the variable.

C. reference to the entire structure can’t be passed.

D. changes cannot be made when reference to a structure is passed.

Right Answer is: B

SOLUTION

In call by reference, the original values get changed.


Q. 193262 If a structure is defined as global, its variables


A. can’t be declared in main( ).

B. can be declared in any function.

C. can’t be passed to any function.

D. can't be returned from any function.

Right Answer is: B

SOLUTION

When a structure is defined as global, then its members also become global. Thus, they can be used by any function.


Q. 193263 Given, function call: fun (a.x, a.y); then,


A. the members are being passed by reference.

B. the first one is being passed by value and the other by reference.

C. the members are being passed by value.

D. we cannot tell how the members are being passed.

Right Answer is: C

SOLUTION

Both are being passed by value since, no reference variable is being used.


Q. 193264 If, Function call : fun(a, b.c); Function prototype : void fun(int, int&) then, the


A. structure member is being passed by value.

B. structure member is being passed by reference.

C. structure member will not be passed at all.

D. structure member will lose its value.

Right Answer is: A

SOLUTION

Here the structure variable is being passed by value. As a result, there wouldn’t be any change in the values of the structure variable.


Q. 193265 An array of structure has elements


A. of different data types.

B. of same data types.

C. which are themselves arrays.

D. which are themselves structures.

Right Answer is: D

SOLUTION

An array can never contain elements of different data types.


Q. 193266 To access a member c of structure C in variable cc, the statement would be


A. C.c;.

B. C.cc.c;.

C. cc.c;.

D. C.cc;.

Right Answer is: C

SOLUTION

Since c is a member of variable cc therefore, cc.c is used to access it.


Q. 193267 The output of the code given below is:
#include < iostream.h >
struct Sumval
{
int a,b;
}
void Struct_Fun(SumVal Sv)
{
Sv.b = 2.5;
cout<< Sv.a << Sv.b;
}
void main ( )
{
Sumval Sv;
Sv.a=100;
Sv.b=1.5;
Struc_Fun(Sv);
cout<< Sv.a << Sv.b;
}


A. 10021001

B. 10021100

C. 10011002

D. 20010012

Right Answer is: A

SOLUTION

cout will display the values of a and b, which are the members of function struct. These members are called with the help of dot operator.


Q. 193268 A structure brings together a group of


A. items of the same data type.

B. related data items.

C. integers with user defined names.

D. variables.

Right Answer is: B

SOLUTION

A structure is a utility to access 2 or more interrelated variables.


Q. 193269 The proper declaration of a variable of struct foo is


A. struct foo;.

B. foo var;.

C. foo;.

D. int foo;.

Right Answer is: A

SOLUTION

A structure is declared using the struct keyword, followed by its name.


Q. 193270 The number of variables, that can be declared when structure is defined without a tag is


A. one.

B. none.

C. many.

D. two.

Right Answer is: A

SOLUTION

While declaring a structure without a tag, only one variable can be declared.


Q. 193271 By default, the members of a structure are


A. protected.

B. private.

C. public.

D. friend functions.

Right Answer is: C

SOLUTION

In structures, by default the members are public while in classes, they are private.


Q. 193272 A structure within a structure is called


A. enclosed structure.

B. nested structure.

C. doubled structure.

D. single structure.

Right Answer is: B

SOLUTION

Nested structures contain structures within structures.


Q. 193273 An array in a structure


A. can have elements of different data type.

B. can have elements of the struct data type.

C. always have elements of the same data type.

D. can also define a structure within it.

Right Answer is: C

SOLUTION

An array wherever being declared, should contain elements of the same data type.


Q. 193274  State 2 things as to what should the function main( ) primarily consist of ?
A. can have elements of different data type.
B. can have elements of the struct data type.
C. always have elements of the same data type.
D. can also define a structure within it.

Right Answer is:

SOLUTION

 a) Program always begins its execution by the main( ) function.
 b) This function primarily consist of function calls.


Q. 193275  What is the situation when function prototype is not needed?
A. can have elements of different data type.
B. can have elements of the struct data type.
C. always have elements of the same data type.
D. can also define a structure within it.

Right Answer is:

SOLUTION

Function prototype is not needed when the function definition appears before its calling function.

 

 

 

         

 


Q. 193276 Write a program to find larger of the two numbers using functions.
A. can have elements of different data type.
B. can have elements of the struct data type.
C. always have elements of the same data type.
D. can also define a structure within it.

Right Answer is:

SOLUTION

A program to find larger of the two numbers using functions is:

#include< iostream.h>

#include< conio.h>

int main()

{

  clrscr();

  int x,y;

  void largest(int , int );// FUNCTION DECLARATION

  cout <<"Enter two numbers";

  cin>> x>> y;

  largest (x,y);

  getch();

  return 0;

}

void largest(int x, int y)

{

if(x < y)

cout<< y <<" is largest";

else if(x > y)

cout<< x<<" is largest";

else

cout<< x<<"and"<< y<<"are equal";

}

Output:


Q. 193277 Write a program to show that the arguments are passed by reference.
A. can have elements of different data type.
B. can have elements of the struct data type.
C. always have elements of the same data type.
D. can also define a structure within it.

Right Answer is:

SOLUTION

A program to show that the arguments are passed by reference:

#includeh>

#include

void duplicate(int&a, int&b, int&c)

{

a*=2;

b*=2;

c*=2;

}

int main()

{

int x=2, y=6, z=8;

duplicate(x,y,z);

cout<<”x=”<< x<<”, y=”<< y<<”, z=”<< z;

getch();

}

Output:


Q. 193278 What will be the output of the following program?
A. can have elements of different data type.
B. can have elements of the struct data type.
C. always have elements of the same data type.
D. can also define a structure within it.

Right Answer is:

SOLUTION

#include< iostream.h>

#include< conio.h>

#include< string.h>

void chg(char * &nm)

{

strcpy(nm, "batra");

}

void main()

{

char name[ ] = "shweta";

cout<< name << "t";

chg(name);

cout<< name << "t";

getch();

}

Output of the above program would be:


Q. 193279 Explain the role of return statement in a function.
A. can have elements of different data type.
B. can have elements of the struct data type.
C. always have elements of the same data type.
D. can also define a structure within it.

Right Answer is:

SOLUTION

The return statement stops the executions and returns back to the calling function. When a return statement is executed, the function is terminated at that point.

Return statement is optional in a void function, whereas if a function returns a value, it must have a return statement.

Multiple return statements often increase complexity.  


Q. 193280 Find the error, if any, in the following function definitions:

( a)  void  abc ( int a, int b)         {              int  c;                     .............              return  (c);         }        (b) int  abc ( int a, int b) {   ....................   .................... }   (c) void  abc  ( void) {    ...................    ....................    return;  }
A. can have elements of different data type.
B. can have elements of the struct data type.
C. always have elements of the same data type.
D. can also define a structure within it.

Right Answer is:

SOLUTION

(a) void abc (int a,int b)

                         {

                               int c;

                               -------------

                          }

(b) int abc (int a; int b)

        {

             int c;

             -----------

             return(c);

          }

         

(c) void abc (void)

                          {

                           int c;

                           -------------

                           }


Q. 193281 What is prototyping? Why is it necessary?
A. can have elements of different data type.
B. can have elements of the struct data type.
C. always have elements of the same data type.
D. can also define a structure within it.

Right Answer is:

SOLUTION

Prototypes enable the compiler to provide stronger type checking. The compiler also catches the differences between the numbers of arguments used to call a function and the number of parameters in the function. It is a good programming style to declare the prototypes in the global declaration section, before the main. It adds flexibility, provides excellent quick reference to the functions used in the program and enhances documentation.


Q. 193282 Mention the similarities between function prototype and function Definition?
A. can have elements of different data type.
B. can have elements of the struct data type.
C. always have elements of the same data type.
D. can also define a structure within it.

Right Answer is:

SOLUTION

Both function prototype and function definition should have must exactly have the same (i) return type (ii) function name and (iii) same argument / parameter list with same number and type in both.

 


Q. 193283 What are local prototypes ?
A. can have elements of different data type.
B. can have elements of the struct data type.
C. always have elements of the same data type.
D. can also define a structure within it.

Right Answer is:

SOLUTION

When function prototype appear within the defiition of calling function, it is Known as local prototype. It is local to the block in which it appears and to the blocks which appear under that block.

 


Q. 193284 What is the difference between a function declaration and function definition ?  
A. can have elements of different data type.
B. can have elements of the struct data type.
C. always have elements of the same data type.
D. can also define a structure within it.

Right Answer is:

SOLUTION

In Declaration you will just declare the function with its return type, which shows that this function will be used in future. and usually declaration is done before starts the main loop.

In Definition you will define the function including its body and all statements, which does some tasks.


Q. 193285 “A program should many small functions “ Give 3  reasons for the statement?  
A. can have elements of different data type.
B. can have elements of the struct data type.
C. always have elements of the same data type.
D. can also define a structure within it.

Right Answer is:

SOLUTION

Many small functions in a program make  it easier for ---
a)     program maintenance
b)     updation of the program and
c)     debugging of the program

 

 


Q. 193286 What are the three parts of  functions ?
A. can have elements of different data type.
B. can have elements of the struct data type.
C. always have elements of the same data type.
D. can also define a structure within it.

Right Answer is:

SOLUTION

Three parts of a functions are:-
i)     Function declaration
ii)    Accessing a function. 
iii)   Returning from function.

 

 


Q. 193287  What are the advantages of using functions ?
A. can have elements of different data type.
B. can have elements of the struct data type.
C. always have elements of the same data type.
D. can also define a structure within it.

Right Answer is:

SOLUTION

 Advantages of using functions are:
       i)      They make program easier by handling small part of the program at a time.
       ii)     Avoid ambiguity.  
       iii)    They reduce program size.
       iv)    Make program more readable and understandable.


Q. 193288 Write a program in C++ to explain the concept of a function.
A. can have elements of different data type.
B. can have elements of the struct data type.
C. always have elements of the same data type.
D. can also define a structure within it.

Right Answer is:

SOLUTION

A program to explain the concept of a function is:

#include< iostream.h>

#include< conio.h>

 int cube(int a);// function declaration

 void main()

{

int x, result;

clrscr();

cout<<"Enter the number";

cin>> x;

result=cube(x); // calling the function

cout<<"n Cube of "<< x<<"n is n"<< result;

getch();

}

int cube(int a) // function definition

{

int compute;

compute=a*a*a;

return(compute);

}

Output:


Q. 193289 Write a program to return more than one value.
A. can have elements of different data type.
B. can have elements of the struct data type.
C. always have elements of the same data type.
D. can also define a structure within it.

Right Answer is:

SOLUTION

A program to return more than one value is:

#include< iostream.h>

#include< conio.h>

void prevnext(int x, int&prev, int&next)

{

prev=x-1;

next=x+1;

}

int main()

{

int x=98, y, z;

prevnext(x,y,z);

cout<<”Previous=”<< y<<”,Next=”<< z;

getch();

return 0;

}

Output:


Q. 193290 Write a function to show the addition of two numbers.
A. can have elements of different data type.
B. can have elements of the struct data type.
C. always have elements of the same data type.
D. can also define a structure within it.

Right Answer is:

SOLUTION

The program to show the addition of two numbers:

#include< iostream.h>

#include< conio.h>

 

int add(int c, int d)

{

 int z;

 z=c+d;

 return (z);

}

 

int main()

{

 int a, b, sum;

 clrscr();

 cout<<"nEnter two numbers to add";

 cin>> a>> b;

 sum=add(a,b);

 cout<<"The result is "<< sum;

 getch();

 return 0;

}

Output:


Q. 193291 To access the structure members, we use


A. >> or ->.

B. << or period(.).

C. period(.) or ->.

D. period and {}.

Right Answer is: C

SOLUTION

We can access the structure member with the help of . or -> operator.


Q. 193292 Body of structure is terminated by:


A. }

B. ]

C. ;

D. .

Right Answer is: C

SOLUTION

A structure is a user defined data type. The body of structure is terminated using semicolon( ;).


Q. 193293 In structures, members are public by default while in classes they are


A. protected

B. public

C. private

D. default

Right Answer is: C

SOLUTION

Technically in C++, there is no difference between a structure and a class. By default, all members are public in a structure whereas all members are private by default in a class.


Q. 193294 How do we define a function?
Right Answer is:

SOLUTION

We define the function as:

Type function-name (parameter list)

{

body

}


Q. 193295 Give one example of built-in functions.
Right Answer is:

SOLUTION

An example of built-in function is: exit().


Q. 193296 Name the C++ functions which are defined by the user.
Right Answer is:

SOLUTION

C++ allows the programmers to define their own functions. These functions are called user-defined functions.


Q. 193297 Define the term ‘function’.
Right Answer is:

SOLUTION

A function is a subprogram that acts on data and often returns a value.


Q. 193298 Define the term ‘function prototype’.
Right Answer is:

SOLUTION

A function prototype is a declaration of the function that tells the program about the type of the value returned by the function and the number and type of arguments.


Q. 193299 Explain the term ‘actual parameter’?
Right Answer is:

SOLUTION

The values that are passed when the function is called are called arguments or actual parameters.


Q. 193300 Differentiate between call by value and call by reference.
Right Answer is:

SOLUTION

A function can be invoked in two ways: 
Call by value 
Call by reference 
In call by value, the method copies the values of actual parameters, whereas in call by reference, a reference or the address of the original variable is passed.


PreviousNext