日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

c语言运算程序示例,C语言算术运算示例程序

發布時間:2023/12/14 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 c语言运算程序示例,C语言算术运算示例程序 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

基本算術運算包括加法,減法,乘法和減法。它們一般對數字數據類型執行基本算術運算,如:int,float和double。

加法操作

下面給出的示例代碼解釋了C語言中的加法運算符:

#include int main() { int op1, op2, sum; // variable declaration op1 = 5; // variable definition op2 = 3; sum = op1 + op2; // addition operation printf("sum of %d and %d is %d", op1, op2, sum); }

執行上面示例代碼,得到以下結果 –

sum of 5 and 3 is 8

減法運算

C語言中的減法運算,如下面給出的示例代碼 –

#include int main() { int op1, op2, sub; // variable declaration op1 = 5; // variable definition op2 = 3; sub = op1 - op2; // subtraction operation printf("Output of %d ? %d is %d", op1, op2, sub); }

執行上面示例代碼,得到以下結果 –

Output of 5 ? 3 is 2

乘法運算

下面給出的示例代碼說明了C語言中的乘法。星號(*)用作乘法運算符。

#include int main() { int op1, op2, mul; // variable declaration op1 = 5; // variable definition op2 = 3; mul = op1 * op2; // multiplication operation printf("Output of %d multiplied by %d is %d", op1, op2, mul); }

執行上面示例代碼,得到以下結果 –

Output of 5 multiplied by 3 is 15

除法運算

下面給出的示例代碼說明了C語言中的除法運算。如下代碼所示 –

#include int main() { int op1, op2, div; // variable declaration op1 = 6; // variable definition op2 = 3; div = 6 / 3; // division operation printf("Output of %d divide by %d is %d", op1, op2, div); }

執行上面示例代碼,得到以下結果 –

Output of 6 divide by 3 is 2

¥ 我要打賞 糾錯/補充 收藏

總結

以上是生活随笔為你收集整理的c语言运算程序示例,C语言算术运算示例程序的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。