Вы находитесь на странице: 1из 2

1.Define the term recursion?

Recursion is a process in which a function calls itself as a subroutine.


This allows the function to be repeated several times,
since it calls itself during its execution.
Functions that incorporate recursion are called recursive functions.

2.what are formal arguments?


Arguments which are mentioned in the definition of the function is called formal arguments.
Formal arguments are very similar to local variables inside the function.
Just like local variables, formal arguments are destroyed when the function ends.
example:
int factorial(int n)
{
// write logic here
}
Here n is the formal argument.

3.what is the use of auto storage class?


The auto storage class specifier. The auto storage class specifier lets you explicitly declare a
variable with automatic storage.
The auto storage class is the default for variables declared inside a block.
A variable x that has automatic storage is deleted when the block in which x was declared
exits.

4.what is meant by scope of variable within a progeam?


A scope in any programming is a region of the program where a defined variable can have its
existence and beyond that variable it cannot be accessed.
There are three places where variables can be declared in C programming language - Inside a
function or a block which is called local variables.

5.Differentiate the formal and actual arguments?

Actual vs Formal Parameters

The Actual parameters are the values that are passed to the function when it is invoked. The
Formal Parameters are the variables defined by the function that receives values when the
function is called.
Related Function
The actual parameters are passed by the calling function. The formal parameters are in the
called function.
Data Types
In actual parameters, there is no mentioning of data types. Only the value is mentioned. In
formal parameters, the data types of the receiving values should be included.
6.Define call by value with examples
The call by value method of passing arguments to a function copies the actual value of an
argument into the formal parameter of the function.
In this case, changes made to the parameter inside the function have no effect on the
argument.
By default, C programming uses call by value to pass arguments.

7.Define call by reference with examples


The call by reference method of passing arguments to a function copies the address of an
argument into the formal parameter.
Inside the function, the address is used to access the actual argument used in the call.
It means the changes made to the parameter affect the passed argument.

8.how do you define a function?


1 A function is a process or a relation that associates each element x of a set X,
the domain of the function, to a single element y of another set Y (possibly the same set), the
codomain of the function.
2 A function is uniquely represented by the set of all pairs (x, f (x)), called the graph of the
function.

9.what is the need for using user defined functions?


A user defined function is an implementation of some action wrapped in an interface (the name
and the defined set of inputs and outputs).
Once you've defined it, you can call it in other places in your code without caring about how it
does what it does;
all you need to know is the interface and purpose.

10.what is a function prototype?


A function prototype is a function declaration that specifies the data types of its arguments in
the parameter list.
The compiler uses the information in a function prototype to ensure that the corresponding
function definition and all corresponding function declarations and calls within
the scope of the prototype contain the correct number of arguments or parameters, and that
each argument or parameter is of the correct data type.

Вам также может понравиться