c code to + , - , / , *

  • c+ , - , / , *
  • implement add , subtract , multiply and divide in c

    Write a program to add subtract, multiply and divide two numbers using user-defined functions with the return type.

    Code

    #include <stdio.h> #include <stdlib.h> #include <string.h> int add(int a, int b) { return a + b; } int multiply(int a, int b) { return a * b; } int subtract(int a, int b) { if (a > b) { return a - b; } else return b - a; } int main() { int x,y,a,b,c; printf("enter the two numbers\n"); scanf("%d",&x); scanf("%d",&y); a=add(x,y); printf("add of the two numbers :%d\n",a); b=multiply(x,y); printf("multi of the two numbers :%d\n",b); c=subtract(x,y); printf("sub of the two numbers :%d\n",c); return 0; }