Function Code In C

Function Code In C

Function Code In C

Function Code In C





Function Code In C

     It has 4 types
     1. Function without argument and without return type
     2. Function with argument and with return type
     3. Function without argument and with return type
     4. Function with argument and without return type
     5. Function defination
     6. Function calling
     7. Function declaration

 Function without argument and without return type
Program :

#include
#include
void santhosh();
void main()
{
clrscr();
santhosh();
getch();
void santhosh()
{
int a,b,c;
printf("Enter the value of a and b is:");
scanf("%d%d",&a,&b);
c=a+b;
printf("The value of c is%d",c);
}

Function with argument and with return type
Program :

#include
#include
int santhosh(int a, int b);
void main()
{
int a,b,c;
clrscr();
printf("Enter the value of a and b is:");
scanf("%d%d",&a,&b);
c=santhosh(a,b);
printf("The value of c is%d",c);
getch();
}
int santhosh(int a,int b)
{
int c;
c=a+b;
return c;
}

Function without argument and with return type
Program :

#include
#include
int santhosh();
void main()
{
int c;
clrscr();
c=santhosh();
printf("The value of c is%d",c);
getch();
}
int santhosh()
{
int a,b,c;
printf("Enter the value of a and b is:");
scanf("%d%d",&a,&b);
c=a+b;
return c;
}


Function with argument and without return type
Program :

#include
#include
void santhosh(int a,int b);
void main()
{
int a,b;
clrscr();
santhosh(a,b);
getch();
}
void santhosh(int a,int b)
{
int c;
printf("Enter the valu of a and b is:");
scanf("%d%d",&a,&b);
c=a+b;
printf("The value of c is%d",c);
}

Post a Comment

1 Comments