c program to add two integers by passing arguments to function using pointers
#include<stdio.h>
void sum(int *a,int *b,int *t);//fn declaration
int main()
{
int num1,num2,total;
printf("\n Enter first number");
scanf("%d",&num1);
printf("Enter the second number");
scanf("%d",&num2);
sum( &num1,&num2,&total);//fn calling
printf("\n the sum total is %d",total);
return 0;
}
//fn definition
void sum(int *a,int *b,int *t) // fn
{
*t=*a+*b;
}
void sum(int *a,int *b,int *t);//fn declaration
int main()
{
int num1,num2,total;
printf("\n Enter first number");
scanf("%d",&num1);
printf("Enter the second number");
scanf("%d",&num2);
sum( &num1,&num2,&total);//fn calling
printf("\n the sum total is %d",total);
return 0;
}
//fn definition
void sum(int *a,int *b,int *t) // fn
{
*t=*a+*b;
}
Comments
Post a Comment