C Practice Test on Functions

This “C Practice Test on Functions” providing set of technical and objective type questions on Functions to test your programming skills.


1. Find the output of following program
#include<stdio.h>
void fun(int);
void main()
{
int i=3;
fun(i);
printf(“%d\n”,i);
}
void fun(int i)
{
++i ;
}

 
 
 
 

2. What is the output of following code?
#include<stdio.h>
void fun(int);
void main()
{
int x=2;
fun(x++);
}
void fun(int x)
{
printf(“x value : %d\n”,x++);
}

 
 
 
 

3. Find the output of following program
void main()
{
abc(3);
}
void abc(int a)
{
printf(“%d”,a);
if(a)
{
abc(a-1);
}
printf(“%d”,a);
}

 
 
 
 

4. What is the output of following code?
#include <stdio.h>
void abc(int a)
{
++a;
printf(“%d”,a);
}
void main()
{
int a=10;
abc(++a);
abc(a++);
printf(“%d”,a);
}

 
 
 
 

5. A function that calls itself for its processing is known as

 
 
 
 

6. Variables inside the parenthesis of functions declarations have _____ level access.

 
 
 
 

7. What is the output of following code?
#include <stdio.h>
void xyz(int, int);
void main(){
int a=1;
xyz(++a,a++);
xyz(a++,++a);
printf(“%d,”,a);
}
void xyz(int x, int y)
{
printf(“%d,%d,”,x,y);
}

 
 
 
 

8. Recursive functions are executed in which order

 
 
 
 

9. Find the output of following program
#include<stdio.h>
void f(int, int);
void main()
{
int i=10;
f(i, i++);
printf(“%d\n”,i);
}
void f(int i, int j)
{
if(i>40)
return;
i+=j;
f(i,j);
printf(“%d\n”,i);
}

 
 
 
 

10. Usually, the loop’s working is faster than recursion

 
 
 
 

Question 1 of 10

Share this