Write a program to accept two numbers to perform addition, subtraction, multiplication ,division between them using user defined function called add() , sub() , div() and mul().

Share

source

#include <stdio.h>
#include <conio.h>
void add(int , int);
void sub(int , int);
void mul(int , int);
void div(int , int);
int main(){
        
        printf("Enter the two numbers");
        int x,y;
        scanf("%d %d",&x,&y);
        
        add(x,y);
        sub(x,y);
        mul(x,y);
        div(x,y);
        
        return 0;

}
void add(int x,int y){
 printf("%d\n",x+y);
}
void sub(int x,int y){
  printf("%d\n",x-y);
}
void mul(int x,int y){
    printf("%d\n",x*y);
    }
void div(int x,int y){
    float result=(float)x/y;
    printf("%f\n",result);
}

output

Share
%d bloggers like this: