「C言語」算術演算子を利用するサンプル

算術演算子
+ 足し算
- 引き算。
* かけ算
/ 割り算
% 剰余算
サンプル

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
#include <stdio.h>
int main(void) {
printf("3 + 4 = %d\n", 3+4);
printf("5 - 3 = %d\n", 5-3);
printf("7 * 8 = %d\n", 7*8);
printf("8 / 2 = %d\n", 8/2);
printf("9 / 2 の余り = %d\n", 9%2);
return 0;
}
#include <stdio.h> int main(void) { printf("3 + 4 = %d\n", 3+4); printf("5 - 3 = %d\n", 5-3); printf("7 * 8 = %d\n", 7*8); printf("8 / 2 = %d\n", 8/2); printf("9 / 2 の余り = %d\n", 9%2); return 0; }
#include <stdio.h>
 
int main(void) {
 
  printf("3 + 4 = %d\n", 3+4);
  printf("5 - 3 = %d\n", 5-3);
  printf("7 * 8 = %d\n", 7*8);
  printf("8 / 2 = %d\n", 8/2);
  printf("9 / 2 の余り = %d\n", 9%2);
 
  return 0;
}

結果
3 + 4 = 7
5 – 3 = 2
7 * 8 = 56
8 / 2 = 4
9 / 2 の余り = 1

C++

Posted by arkgame