Beruflich Dokumente
Kultur Dokumente
SECTION – A
(UNIT – 4)
Category – 1 (Easy)
Category – 2 (Moderate)
#include<stdio.h>
int func(int a){
return a*a;
}
int func(int a, int b=7){
return a*b;
}
void main(){
printf(“%d”, func(15));
}
3. Write a C program to compute factorial of a number recursively.
4. Deduce the output of the following code:
#include <stdio.h>
int main()
{
static int i=5;
if(--i){
main();
printf("%d ",i);
}
}
5. Compute the output of the following code:
#include <stdio.h>
int fun()
{
static int num = 16;
return num--;
}
int main()
{
for(fun(); fun(); fun())
printf("%d ", fun());
return 0;
}
Section – B
(UNIT – 4)
Typical Questions
1. Discuss the implementation of function prototyping, function definition, function call with
the help of an example.
2. Compare call by value and call by reference with the help of an example.
3. Compare and contrast the various storage classes with example.
4. Illustrate the use of function overloading with example?
5. Explain Dynamic Memory Allocation and its need.
Moderate Questions
1. Write a program to create an array for entering student information and total marks secured
by them at run time. Create function to compute and display average marks scored for the
group of students. Additional data structure/function can be created if required.
2. Write a C function that computes multiplication of two matrices passed as argument to the
function and return the resultant matrix. Write a program to utilize the created
multiplication and display the result of two user input matrices. You can create helper
functions if needed.
3. Write the recursive function to compute Fibonacci series.
4. Refer the following code:
int main()
{
int x, y;
printf("Enter the value of x and y\n");
scanf("%d%d",&x,&y);
printf("Before Swap:\nx=%d\ny=%d\n", x, y);
swap(&x, &y);
printf("After Swap:\nx=%d\ny=%d\n", x, y);
return 0;
}
void swap(int *a, int *b)
{
int t;
t = *b;
*b = *a;
*a = t;
}
Justify the usage of call by address instead of call by value.
5. How is dynamic memory allocation performed? Explain the functions used in dynamic
memory allocation & deallocation with example.
6. Create a C program for solving the Tower of Hanoi problem.
Easy Questions
Section – C
1. Is it always useful to modularize the code by creating functions. Defend the suggestion with
appropriate examples.
2. Relate use cases where function pointer will be useful.