SESSION:31

FOR DOWNLOADING .pdf FILE PLEASE CLICK HERE.
(The .pdf file is password protected, write your email in comment box to get password.)


1)       What are the elements of user-defined function?
There are three elements of user-defined function. These elements are as follows:
·         Function Definition
·         Function Call
·         Function Declaration
2)       What are the elements of function definition?
Function Definition shall include the following elements:
·         Function Name
·         Function Type.
·         List of Parameters
·         Local Variable Declaration
·         Function Statement
·         Return Statement.
3)       What are the similarities between variables and functions?
They both have the following similarities:
·         They both adhere to the rule of Identifier.
·         Both have a type associated with it.
·         Their type must be declared and defined before they are used.
4)       What are the different categories of a function?
The different categories of a function are:
·         Function With No Argument And No Return Value.
·         Function With Argument And No Return Value.
·         Function With Argument And One Return Value.
·         Function With No Argument But Return A Value.
·         Function That Return Multiple Value.
5)       What are the rules for passing an array to a function?
There are three different rules for passing an array to a function:
·         The function must be called by passing the name of an array.
·         In function definition the size of the array does not need to be specified.
·         The function prototype must show that the argument is in array.
6)       What is the difference between Automatic variable and static variable?
Automatic variables are created when an already existing function is called and destroyed automatically while the Static variable can be declared anywhere in the program by using static keyword.
7)       What are the different ways of parameter passing?
There are two different ways of passing data from one function to another:
·         Pass by Value: Actual parameter is copied to the variable in the parameter list of the called function.
·         Pass by Reference: Memory address of the variable is sent to the called function.
8)       What is the difference between global prototype and local prototype?
When we place the declaration above all the function it is called global prototype while when the prototype is in the function definition it is called local prototype.
9)       Is it possible to execute code even after the program exits the main() function?
C library consists of a function named at exit() that can be used to perform “cleanup” operations when your program terminates. We can set up a set of functions you want to perform automatically when your program exits by passing function pointers to the at exit() function.
10)     Is using exit() the same as using return?
No. The exit() function is used to exit from your program and the return function is used to return from a function and return control to the calling function.
11)    Explain the use of fflush() function?
It is used to empty the buffer associated with the o/p stream.
12)    What is the difference b/w malloc() and calloc()?
Malloc allocates uninitialized memory while calloc initializes the allocated memory with a constant (0).
Malloc uses single parameter while calloc uses 2 parameters to initialize memory.
13)    What is virtual function?
A virtual function is a member function that is declared within a base class and redefined by a derived class.
14)    What is the output of the following program?
main()
{
int x=20;
int y=10;
swap(x,y);
printf(“%d %d”,y,x+2);
}
swap(int x,int y)
{
int temp;
temp =x;
x=y;
y=temp;
}
Answer: 10 22 (duplicate copy of arguments are generated on calling a function)
15)    What is the format function?
Format function allows us to supply the input in a fixed format and let us obtain the output in the specified form. Formatted output converts the internal binary representation of the data to ASCII character which are written to the output file. And we can also define the Random access, Random access means we can move to any part of a file and read or write data from it without reading the entire file. We can access it in two ways, one is sequentially and other is randomly.
16)    How many types of formatted functions are there?

There are two types of formatted function. One is fprintf and second is fscanf.

No comments:

Post a Comment