輸入在一行中給出2個正整數(shù)A和B。
輸出格式:
在5行中按照格式“A 運算符 B = 結果”順序輸出和、差、積、商與余數(shù)。文章來源:http://www.zghlxwxcb.cn/news/detail-712803.html
輸入樣例:
5 3
輸出樣例:
在這里給出相應的輸出。例如:文章來源地址http://www.zghlxwxcb.cn/news/detail-712803.html
5 + 3 = 8
5 - 3 = 2
5 * 3 = 15
5 / 3 = 1
5 % 3 = 2
#include <stdio.h>
int main()
{
int a,b;
scanf("%d %d",&a,&b);
printf("%d + %d = %d\n",a,b,a+b);
printf("%d - %d = %d\n",a,b,a-b);
printf("%d * %d = %d\n",a,b,a*b);
printf("%d / %d = %d\n",a,b,a/b);
printf("%d %% %d = %d\n",a,b,a%b);
return 0;
}
到了這里,關于本題要求編寫程序,計算并輸出2個正整數(shù)的和、差、積、商與余數(shù)。題目保證輸入和輸出全部在整型范圍內。的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!