# Write a C program to add two numbers using Call by value and Call by reference parameter passing techniques.

CALL BY VALUE: PROGRAM

```#include&lt;stdio.h&gt;
main()
{
int a,b,sum=0;
clrscr();
printf(&quot;Enter the values of a and b\n&quot;);
scanf(&quot;%d%d&quot;,&amp;a,&amp;b);
printf(&quot;a:%d, b:%d, sum:%d\n&quot;,a,b,sum);
printf(&quot;a:%d, b:%d,\nsum:%d\n&quot;,a,b,sum);
getch();
}
int add( int num1,int num2)
{
int sum=0;
printf(&quot;num1:%d, num2:%d, sum:%d\n&quot;,num1,num2,sum);
sum=num1+num2;
printf(&quot;num1:%d, num2:%d, sum:%d\n&quot;,num1,num2,sum);
return(sum);
}```

Output

```Output:
Enter the values of a and b
5
6
a:5, b:6, sum:0
num1:5, num2:6, sum:0
num1:5, num2:6, sum:11
a:5, b:6,
sum:11
Enter the values of a and b
15
30
a:15, b:30, sum:0
num1:15, num2:30, sum:0
num1:15, num2:30, sum:45
a:15, b:30,
sum:45```

CALL BY REFERENCE
PROGRAM:

```#include&lt;stdio.h&gt;
void addnum(int *pa,int *pb,int *psum);
main()
{
int a,b,sum=0;
clrscr();
printf(&quot;Enter the values of a and b\n&quot;);
scanf(&quot;%d%d&quot;,&amp;a,&amp;b);
printf(&quot;a:%d\u, b:%d, sum:%d\n&quot;,a,b,sum);
printf(&quot;pa:%u pb:%u psum:%u\n&quot;,&amp;a,&amp;b,&amp;sum);
printf(&quot;a:%d, b:%d, sum:%d\n&quot;,a,b,sum);
getch();
}
void addnum(int *pa,int *pb,int *psum)
{
printf(&quot;add the pointer variables\n&quot;);
printf(&quot;pa:%u pb:%u psum:%u\n&quot;,*pa,*pb,*psum);
printf(&quot;values in pointer variables are\n&quot;);
printf(&quot;pa:%u pb:%u psum:%u\n&quot;,*pa,*pb,*psum);
*psum=*pa+*pb;
}```

```OUTPUT:
Enter the values of a and b
10
14
a:10u, b:14, sum:0
pa:65494 pb:65496 psum:65498
add the pointer variables
pa:10 pb:14 psum:0
values in pointer variables are
pa:10 pb:14 psum:0
a:10, b:14, sum:24
Enter the values of a and b
45
15
a:45u, b:15, sum:0
pa:65494 pb:65496 psum:65498
add the pointer variables
pa:45 pb:15 psum:0
values in pointer variables are
pa:45 pb:15 psum:0
a:45, b:15, sum:60```