เครื่องหมาย | สัญลักษณ์ | ตัวอย่าง | ผลลัพท์ |
---|---|---|---|
บวก | + | A + B | ผลรวมของทั้งสอง |
ลบ | - | A - B | หักค่าจำนวน B ออกจาก A |
คูณ | * | A * B | ผลคูณของทั้งสอง |
หาร | / | A / B | ตัวตั้งคือ A ตัวหารคือ B |
มอดูลัส | % | A % B | เศษที่เหลือจากการหาร A ด้วย B |
5 % 3
5 % -3
-5 % 3
-5 % -3
5 % 5
5 % 30
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main(void) | |
{ | |
int a, b; | |
float x, y; | |
a = 10; | |
b = 4; | |
x = 10.5; | |
y = 3; | |
printf("%d\n", a + b); | |
printf("%f\n", x - y); | |
printf("%f\n", x * y); | |
printf("%f\n", x / y); | |
printf("%d\n", a % b); | |
//printf("%d\n", x % y); | |
int c; | |
c = 10; | |
printf("%d\n",++c); | |
printf("%d",c); | |
return 0; | |
} |