输入两个整数num1和num2,计算并输出它们的和、差、积、商(用实数表示,保留2位小数点)与余数.5/3=1.67
输入两个整数num1和num2,计算并输出它们的和、差、积、商(用实数表示,保留2位小数点)与余数.5/3=1.67
程序如下:
#include
void main()
{
\x05int num1,num2,sum,min,mul,yushu;
\x05float shang;
\x05scanf("%d",&num1);
\x05scanf("%d",&num2);
\x05sum = num1 + num2;
\x05min = num1 - num2;
\x05mul = num1 * num2;
\x05shang = (float)num1 / num2;
\x05yushu = num1 % num2;
\x05printf("%d %d %d %0.2f %d\n",sum,min,mul,shang,yushu);
}
------------------------------------------------------------------------------------------------------------------
再修改一次:
#include
void main()
{
\x05int num1,num2,sum,min,mul,yushu;
\x05float shang;
\x05printf("请输入num1:");
\x05scanf("%d",&num1);
\x05printf("请输入num2:");
\x05scanf("%d",&num2);
\x05sum = num1 + num2;
\x05min = num1 - num2;
\x05mul = num1 * num2;
\x05shang = (float)num1 / num2;
\x05yushu = num1 % num2;
\x05printf("%d + %d=%d\n",num1,num2,sum);
\x05printf("%d - %d=%d\n",num1,num2,min);
\x05printf("%d * %d=%d\n",num1,num2,mul);
\x05printf("%d / %d=%0.2f\n",num1,num2,shang);
\x05printf("%d %% %d=%d\n",num1,num2,yushu);
}