pages

Monday, 14 June 2021

c-program to add two number by using pointer | call by reference | c-programming

program to add two number by pointer in c language

In this program we will now takes two number and add them by using call by reference (pointer)
 Call by Reference :- when address are passed to the called function.


#include<stdio.h>
#include<conio.h>
int add(int *,int *);
void main()
{
         int a,b,sum=0;
         printf("enter the number:-");
         scanf("%d %d",&a,&b);
         sum=add(&a,&b);
         printf("\n the sum of the two number is %d",sum);
         getch();
}
int add(int *x,int *y)
{
         int s;
         s=*x+*y;
         return(s);
}

output :- 


















1 comment: