//A C program to create a user defined function to display the sum of any 2 numbers.
#include<stdio.h>
#include<conio.h>
int sum(int,int);
void main()
{clrscr();
int a,b,c;
printf(“\nEnter first number”);
scanf("%d", &a);
printf(“\nEnter second number”);
scanf("%d", &b);
c = sum(a, b);
printf ("sum is = %d\n", c); getch();
}int sum(int a, int b)
{int c;
c=a+b;
return(c);
}
Output:
#include<stdio.h>
#include<conio.h>
int sum(int,int);
void main()
{clrscr();
int a,b,c;
printf(“\nEnter first number”);
scanf("%d", &a);
printf(“\nEnter second number”);
scanf("%d", &b);
c = sum(a, b);
printf ("sum is = %d\n", c); getch();
}int sum(int a, int b)
{int c;
c=a+b;
return(c);
}
Output:
0 Comments