1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Basic Calculator

Discussion in 'C' started by Anil2447, Aug 28, 2010.

  1. Anil2447

    Anil2447 Guest

    int main()
    char operator;
    int num1, num2;
    //char operation[1]={'\0'};
    printf("Enter two numbers and operator to perform calculations!...\n");
    printf("Enter the operator: ");
    printf("Enter num1: ");
    printf("Enter num2: ");

    if (operator=='+')
    printf("Sum is %d\n",num1+num2);
    else if (operator=='-')
    printf("Difference is %d\n",num1-num2);
    else if (operator=='*'){
    printf("Product is %d\n",num1*num2);
    else if(operator=='/'){
    printf("Ratio is %d\n",num1/num2);
    printf("Not given any Operation.");

    Enter two numbers and operator to perform calculations!...

    Enter the operator: +
    Enter num1: 12
    Enter num2: 13
    Sum is 25


Share This Page