# 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 %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mun.gitbook.io/c/solution/8-character-and-string/7.6-character-arithmetic-operation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
