PowerPoint presentation of functions in C language. It will give you brief idea how function works in C along with its unique features like return statement.
12. #include<stdio.h>
#include<conio.h>
int maxint(int,int); // prototype of the function
int main()
{
int x, y;
int max;
clrscr();
printf(“Enter 2 numbersn”);
scanf(“%d%d”,&x,&qy);
max = maxint(x,y); // function call
printf(“Largest number is %dn”,max);
getch();
}
int maxint(int p, int q)
{
if(p>q)
return p;
else
return q;
}
13.
14. #include<stdio.h>
#include<conio.h>
int maxint(int,int); // prototype of the function
int main()
{
int x, y;
int max;
clrscr();
printf(“Enter 2 numbersn”);
scanf(“%d%d”,&x,&q);
int maxint(int x, int x)
{
if(x>y)
return x;
else
return y;
}
getch();
}
One function block inside other
function block
15. #include<stdio.h>
#include<conio.h>
int maxint(int,int); // prototype of the function
int main()
{
int x, y;
int max;
clrscr();
printf(“Enter 2 numbersn”);
scanf(“%d%d”,&x,&qy);
max = maxint(x,y); // function call
printf(“Largest number is %dn”,max);
getch();
}
int maxint(int p, int q)
{
if(p>q)
return p;
else
return q;
}
16. #include<stdio.h>
#include<conio.h>
int maxint(int,int); // prototype of the function
int main()
{
int x, y;
int max;
clrscr();
printf(“Enter 2 numbersn”);
scanf(“%d%d”,&x,&qy);
max = maxint(x,y); // function call
printf(“Largest number is %dn”,max);
getch();
}
int maxint(int p, int q)
{
if(p>q)
return (p);
else
return q;
}