20_10

Write a program in C to add two numbers using pointers.

 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:

add two numbers using pointers


No comments:

Post a Comment

Write a program in C to convert a decimal number to binary using recursion.

 Source code: //Write a program in C to convert a decimal number to binary using recursion. #include<stdio.h> long convertB_to_D(int d...