Write a program to add,subtract,multiply and divide two integer using user-defined type function with return type
Answer:
#include <stdio.h>
//function declaration
int add(int a,int b);
int subtract(int a,int b);
int multiply(int a,int b);
int divide(int a,int b);
//main function
int main()
{
int a,b;
printf("Enter integer a\n");
scanf("%d",&a);
printf("Enter integer b\n");
scanf("%d",&b);
printf("add is %d\n",add(a,b));
printf("subtract is %d\n",subtract(a,b));
printf("multiply is %d\n",multiply(a,b));
printf("divide is %d\n",divide(a,b));
return 0;
}
//function call to add
int add(int a,int b)
{
int result;
result=( a+ b);
return result;
}
//function call to subtract
int subtract(int a,int b)
{
int result;
result=(a-b);
return result;
}
//function to multily
int multiply(int a,int b)
{
int result;
result=(a*b);
return result;
}
//function to divide
int divide(int a,int b)
{
int result;
result=(a/b);
return result;
}