> 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/2-operator/2.2-arithmetic-operator.md).

# 2.2 Arithmetic Operator

## ২.২ অ্যারিথমেটিক অপারেটর (৫)

1. \[1] দুইটি সংখ্যার যোগফল নির্ণয় কর।
2. \[2] দুইটি সংখ্যার বিয়োগফল নির্ণয় কর।
3. \[3] দুইটি সংখ্যার গুণফল নির্ণয় কর।
4. \[4] দুইটি সংখ্যার ভাগফল নির্ণয় কর।
5. \[5] দুইটি সংখ্যার ভাগশেষ নির্ণয় কর।

## সমাধান

### \[1] দুইটি সংখ্যার যোগফল নির্ণয় কর।

{% code lineNumbers="true" %}

```c
#include<stdio.h>
int main(){
    int a, b, summation;

    scanf("%d%d", &a, &b);
    
    summation = a + b; // Plus Operator

    printf("%d\n", summation);

    return 0;
}
```

{% endcode %}

| Sample Input | Sample Output |
| ------------ | ------------- |
| 5 10         | 15            |
| 2 4          | 6             |
| -5 6         | 1             |
| -5 4         | -1            |
| 6 -4         | 2             |
| 6 -8         | -2            |

### \[2] দুইটি সংখ্যার বিয়োগফল নির্ণয় কর।

{% code lineNumbers="true" %}

```c
#include<stdio.h>
int main(){
    int a, b, difference;

    scanf("%d%d", &a, &b);
    
    difference = a - b; // Minus Operator

    printf("%d\n", difference);

    return 0;
}
```

{% endcode %}

| Sample Input | Sample Output |
| ------------ | ------------- |
| 10 5         | 5             |
| 2 4          | -2            |

### \[3] দুইটি সংখ্যার গুণফল নির্ণয় কর।

{% code lineNumbers="true" %}

```c
#include<stdio.h>
int main(){
    int a, b, product;

    scanf("%d%d", &a, &b);
    
    product = a * b; // Multiplication Operator

    printf("%d\n", product);

    return 0;
}
```

{% endcode %}

| Sample Input | Sample Output |
| ------------ | ------------- |
| 10 5         | 50            |
| 2 -4         | -8            |

### \[4] দুইটি সংখ্যার ভাগফল নির্ণয় কর।

{% tabs %}
{% tab title="Integer Division" %}
{% code lineNumbers="true" %}

```c
#include<stdio.h>
int main(){
    int a, b, quotient;

    scanf("%d%d", &a, &b);
    
    quotient = a / b; // Division Operator // Integer Division

    printf("%d\n", quotient);

    return 0;
}
```

{% endcode %}
{% endtab %}

{% tab title="Float Division" %}
{% code lineNumbers="true" %}

```c
#include<stdio.h>
int main(){
    float a, b, quotient;

    scanf("%f%f", &a, &b);
    
    quotient = a / b; // Division Operator // Float Division

    printf("%f\n", quotient);

    return 0;
}
```

{% endcode %}
{% endtab %}

{% tab title="Double Division" %}
{% code lineNumbers="true" %}

```c
#include<stdio.h>
int main(){
    double a, b, quotient;

    scanf("%lf%lf", &a, &b);
    
    quotient = a / b; // Division Operator // Double Division

    printf("%lf\n", quotient);

    return 0;
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Integer Division" %}

| Sample Input | Sample Output                                      |
| ------------ | -------------------------------------------------- |
| 10 3         | 3                                                  |
| 8 4          | 2                                                  |
| -8 2         | -4                                                 |
| 8 -2         | -4                                                 |
| 5 10         | 0                                                  |
| 10 0         | Error: Division by Zero / Floating point exception |
| {% endtab %} |                                                    |

{% tab title="Float/Double Division" %}

| Sample Input  | Sample Output                                           |
| ------------- | ------------------------------------------------------- |
| 10 3          | 3.333333                                                |
| 8 4           | 2.000000                                                |
| -8 3          | -2.666667                                               |
| 8 -3          | -2.666667                                               |
| 5 10          | 0.500000                                                |
| 10 0          | Error: Division by Zero / Floating point exception, INF |
| {% endtab %}  |                                                         |
| {% endtabs %} |                                                         |

### \[5] দুইটি সংখ্যার ভাগশেষ নির্ণয় কর।

{% code lineNumbers="true" %}

```c
#include<stdio.h>
int main(){
    int a, b, remainder;

    scanf("%d%d", &a, &b);
    
    remainder = a % b; // Modulus Operator
    /* In C Programming,
    *  the Modulus Operator only works with Integer Values
    *  in both numerator denominator
    */

    printf("%d\n", remainder);

    return 0;
}
```

{% endcode %}

| Sample Input | Sample Output |
| ------------ | ------------- |
| 10 3         | 1             |
| 8 4          | 0             |
| 8 3          | 2             |
| -8 3         | -2            |
| 8 -3         | 2             |
| 5 10         | 5             |
