Source code:
/*Write a program in C to add two numbers using pointers. You have to write the fsum() function which accepts the address of two variables and returns the sum of their values to the main function. */
#include <stdio.h>
int fsum(int *n1, int *n2)
{
int sum = 0;
sum = *n1 + *n2;
return(sum);
}
int main()
{
int no1, no2, sum;
printf(" Input the first number : ");
scanf("%d", &no1);
printf(" Input the second number : ");
scanf("%d", &no2);
printf("The sum of the entered numbers is : %d\n",fsum(&no1,&no2));
return 0;
}
Output:
No comments:
Post a Comment