Programs on Functions in C

This “Programs on Functions to practice” providing all kinds of examples to understand clearly how to define and work with functions including recursion.


 

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

‚Äč
Find the output of following program
#include<stdio.h>
void fun(int,int);
void main()
{
int i=6;
fun(i–, –i);
fun(i++, ++i);
printf(“%d\n”,–i);
}
void fun(int x, int y)
{
printf(“%d\n%d\n”,x++,y–);
}

 

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

 

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

Share this