program in c to return more than one value from the function
#include<stdio.h> #include<conio.h> void Fun(int a,int b,int *,int *,int *); int main() { int x,y,sum,dif,mul; printf("Enter two numbers:-"); scanf("%d%d",&x,&y); fun(x,y,&sum,&dif,&mul); printf("Sum = %d \nDifference = %d\nMultiplication = %d",sum,dif,mul); getch(); return 0; } void fun(int a,int b,int *s,int *d,int *m) { *s=a+b; *d=a-b; *m=a*b; }
Output :-
0 Comments