2.2 Arithmetic Operator

⧍.⧍ āĻ…ā§āϝāĻžāϰāĻŋāĻĨāĻŽā§‡āϟāĻŋāĻ• āĻ…āĻĒāĻžāϰ⧇āϟāϰ (ā§Ģ)

  1. [1] āĻĻ⧁āχāϟāĻŋ āϏāĻ‚āĻ–ā§āϝāĻžāϰ āϝ⧋āĻ—āĻĢāϞ āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĨ¤

  2. [2] āĻĻ⧁āχāϟāĻŋ āϏāĻ‚āĻ–ā§āϝāĻžāϰ āĻŦāĻŋā§Ÿā§‹āĻ—āĻĢāϞ āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĨ¤

  3. [3] āĻĻ⧁āχāϟāĻŋ āϏāĻ‚āĻ–ā§āϝāĻžāϰ āϗ⧁āĻŖāĻĢāϞ āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĨ¤

  4. [4] āĻĻ⧁āχāϟāĻŋ āϏāĻ‚āĻ–ā§āϝāĻžāϰ āĻ­āĻžāĻ—āĻĢāϞ āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĨ¤

  5. [5] āĻĻ⧁āχāϟāĻŋ āϏāĻ‚āĻ–ā§āϝāĻžāϰ āĻ­āĻžāĻ—āĻļ⧇āώ āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĨ¤

āϏāĻŽāĻžāϧāĻžāύ

[1] āĻĻ⧁āχāϟāĻŋ āϏāĻ‚āĻ–ā§āϝāĻžāϰ āϝ⧋āĻ—āĻĢāϞ āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĨ¤

#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;
}
Sample Input
Sample Output

5 10

15

2 4

6

-5 6

1

-5 4

-1

6 -4

2

6 -8

-2

[2] āĻĻ⧁āχāϟāĻŋ āϏāĻ‚āĻ–ā§āϝāĻžāϰ āĻŦāĻŋā§Ÿā§‹āĻ—āĻĢāϞ āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĨ¤

#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;
}
Sample Input
Sample Output

10 5

5

2 4

-2

[3] āĻĻ⧁āχāϟāĻŋ āϏāĻ‚āĻ–ā§āϝāĻžāϰ āϗ⧁āĻŖāĻĢāϞ āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĨ¤

#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;
}
Sample Input
Sample Output

10 5

50

2 -4

-8

[4] āĻĻ⧁āχāϟāĻŋ āϏāĻ‚āĻ–ā§āϝāĻžāϰ āĻ­āĻžāĻ—āĻĢāϞ āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĨ¤

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

[5] āĻĻ⧁āχāϟāĻŋ āϏāĻ‚āĻ–ā§āϝāĻžāϰ āĻ­āĻžāĻ—āĻļ⧇āώ āύāĻŋāĻ°ā§āϪ⧟ āĻ•āϰāĨ¤

#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;
}
Sample Input
Sample Output

10 3

1

8 4

0

8 3

2

-8 3

-2

8 -3

2

5 10

5

Last updated