Calculator using C programming

 

    
    #include<stdio.h>
    #include<math.h>
     
    int add(a, b)
    {
    printf("Please enter two number for add: \n");
    scanf("%d%d",&a,&b);
    printf("%d + %d = %d\n",a,b,(a+b));
    return 0;
    }
     
    int sub(a, b)
    {
    printf("Please enter two number for sub (first - second) : \n");
    scanf("%d%d",&a,&b);
    printf("%d - %d = %d\n",a,b,(a-b));
    return 0;;
    }
     
    int mult(a, b)
    {
    printf("Please enter two number for multiplication: \n");
    scanf("%d%d",&a,&b);
    printf("%d * %d = %d\n",a,b,(a*b));
    return 0;
    }
     
    float div(a, b)
    {
    printf("Enter TWO numbers one by one: \n");
    scanf("%d%d",&a,&b);
    printf("%d / %d = %.2f\n",a,b,(float)a/b);
    return 0;
    }
     
    int sqr(a)
    {
    printf("Please a number: \n");
    scanf("%d",&a);
    printf("Square of %d is = %d\n",a,(a*a));
    return 0;
    }
     
    float square_root()
    {
    double a, result;
    printf("Please enter a full square number: \n");
    scanf("%lf",&a);
    result = sqrt(a);
    printf("SquareRoot of %.2lf = %.2lf\n",a,result);
    return 0;
    }
     
    float mod()
    {
    int a, b;
    printf("Please enter a number to get modulus: \n");
    scanf("%d%d",&a,&b);
    printf("%d mod with %d = %d\n",a,b,(a%b));
    return 0;
    }
     
     
     
    int main()
    {
    int add(), sub(), mult(), sqr();
    float div(), square_root(), mod();
    int press;
     
    while (1)
    {
    printf("Select Options: \n********************\n 1 for Sum\n 2 for Subtraction\n 3 for Multiplication\n 4 for Division\n 5 for Square\n 6 for Square Root\n 7 for Modulus\n 8 for Exit \n");
    scanf("%d", &press);
    if(press==1)
    {
    add();
    }
    else if(press==2)
    {
    sub();
    }
    else if(press==3)
    {
    mult();
    }
    else if(press==4)
    {
    div();
    }
     
    else if(press==5)
    {
    sqr();
    }
    else if(press==6)
    {
    square_root();
    }
    else if(press==7)
    {
    mod();
    }
     
    else if(press==8)
    {
    exit (0);
    }
    else
    {
    printf("There is no function assigned with %d\n", press);
    }
    }
     
    return 0;
    }