> For the complete documentation index, see [llms.txt](https://mun.gitbook.io/c/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mun.gitbook.io/c/solution/8-character-and-string/7.6-character-arithmetic-operation.md).

# 7.6 Character Arithmetic Operation

## 7.6 Character Arithmetic Operation

1. \[22] Perform basic arithmetic operations. At first, take two integers and then a symbol of the arithmetic operation as input.
   * Addition (+)
   * Subtraction (-)
   * Multiplication (\*)
   * Division (/)
   * Reminder (%)
   * Power (^)

## সমাধান

### \[22] Perform basic arithmetic operations. At first, take two integers and then a symbol of the arithmetic operation as input.

* Addition (+)
* Subtraction (-)
* Multiplication (\*)
* Division (/)
* Reminder (%)
* Power (^)

{% code lineNumbers="true" %}

```c
#include<stdio.h>
#include<math.h>
int main(){
    int num1, num2;
    char op;
    
    scanf("%d%d %c", &num1, &num2, &op);
    switch(op){
        case '+':
            printf("Result: %d\n", num1 + num2);
            break;
        case '-':
            printf("Result: %d\n", num1 - num2);
            break;
        case '*':
            printf("Result: %d\n", num1 * num2);
            break;
        case '/':
            if (num2 != 0) {
                printf("Result: %f\n", (float)num1 / num2);
            } else {
                printf("Division by zero is not allowed.\n");
            }
            break;
        case '%':
            if (num2 != 0) {
                printf("Result: %d\n", num1 % num2);
            } else {
                printf("Division by zero is not allowed.\n");
            }
            break;
        case '^':
            printf("Result: %d\n", (int)pow(num1, num2));
            break;
        default:
            printf("Invalid operation.\n");
            break;
    }

    return 0;
}
```

{% endcode %}
