Functions
Functions
OUTPUT:
Before swapping
a = 5 , b = 10
In swap function
a = 10 , b = 5
Call by reference:
In this type instead of passing
values,
addresses
are
passed.
Function operates on addresses rather
than
values.
Here
the
formal
arguments are pointers to the actual
arguments.
In
this
type
formal
argument
argument.
points
to
the
actual
OUTPUT:
Before swapping
a = 5 , b = 10
In swap function
a = 10 , b = 5
#include<conio.h>
int sum1(int );
void main()
{
int n,d;
printf(Enter number upto which u want to print series:);
scanf("%d",&n);
d=sum1(n);
printf("\nsum is %d",d);
getch();
}
int sum1(int n)
{
int i=1,sum=0;
while(i<=n)
{
sum = sum+i;
i++;
}
Return(sum1);
}