Short answer types question on Function.

1. How is a function invoked?
A function is invoked(or called) through an output statement or through an assigement statement by using the function name followed by the list of arguments.
Ex: p = prod(x, y);

2. What is the use of the return statement?
The return statement is used in the body of the function which contains the value that has to be sent back to the main program.


3. Give the syntax of return statement?
The return statement can take one of the following forms 
return;
Or
return(expression);
The first form does not return any value, where the second function returns the value of the expression.

4. What are local variables?
Variables declared inside a block or function are said to belong only to that block and these are called as local variables. Values of these variables are valid only in that block.

5. What are global variables?
Variables declared before the main function block are called global variables. Values of these variables are available in every block of that program.

6. What is function prototype?
A function must be declared before it is actually called. The declaration of a function is known as function prototype.

7. Give the syntax of a function prototype.
return-type function-name (type1, type2); Ex: float power(float, int);

8. Define the term recursion.
A function which calls itself directly or indirectly again and again until a condition is satisfied is called as recursive function. This process is called recursion.

9. How do we pass an entire array to a function?
To pass an entire array to a called function only the array name without a subscript is used as argument(actual parameter).
Ex: void main( )
{
int a[100], n;
. . . . . . . . . .
sort(a, n); (where sort is the function name)
}

10. What is meant by scope of a variable?
1. The name of the variable.
2. The amount of space required to store that variable.
3. Address of the memory location.
4. The possible operations, which can be performed with the variable.

11. What are storage classes?
A storage class refers to the scope and life time of a variable i.e., the portion of program where the variable is valid and how long a variable can retain its value is defined in the storage class.


12. What are the different types of storage classes?
1. Automatic storage class
2. External storage class
3. Static storage class
4. Register storage class

13. does Register variable have address?
No. (CPU registers do not have addresses).


Thanks
Mukesh Rajput

Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: