如何编写程序,输入俩个整数num1和num2,计算并输出它们的的和,差,积,商,与余数

是用C语言,谢谢

编写程序有许多语言,假设是C语言吧

#include <stdio.h>

int main(int argc,char **argv)
{
int num1,num2;
int n1;/*和*/
int n2;/*差*/
int n3;/*积*/
int n4;/*商*/
int n5;/*余*/

printf("请输入整数num1=?");
scanf("%d",&num1);
printf("请输入整数num2=?");
scanf("%d",&num2);

n1 = num1 + num2;
n2 = num1 - num2;
n3 = num1 * num2;
n4 = num1 / num2;
n5 = num1 % num2;

printf("和=%d\n",n1);
printf("差=%d\n",n2);
printf("积=%d\n",n3);
printf("商=%d (整除商)\n",n4);
printf("商=%f (浮点商)\n",(double)(num1/num2));
printf("余=%d\n",n5);

}
温馨提示:内容为网友见解,仅供参考
第1个回答  2009-03-14
#include<iostream>
using namespace std;
int main()
{
int num1,num2;
cout<<"输入两个整数:"<<endl;
cin>>num1>>num2;
cout<<"和:"<<num1+num2<<endl;
cout<<"差:"<<num1-num2<<endl;
cout<<"积:"<<num1 * num2<<endl;
cout<<"商:"<<(double)num1/num2<<endl;
cout<<"余数:"<<num1%num2<<endl;
return 0;
}
第2个回答  推荐于2016-12-02
#include <stdio.h>
main()
{ int num1,num2;
int x,y,z,k,j;
print("num1=",num1);
print("num2=",num2);

x=num1+num2;
y=num1-num2;
z=num1*num2;
k=num1/num2;
j=num1%num2;

print("和=",x);
print("差=",y);
print("积=",z);
print("商=",k);
print("余=",j);

}本回答被提问者采纳
第3个回答  2009-03-16
#include "stdio.h"
void main()
{
int num1,num2;
int he,cha,ji,yu;
float shan;
printf("input the two number:");
scanf("%d%d",&num1,&num2);
he=num1+num2;
cha=num1-num2;
ji=num1*num2;
yu=num1%num2;
shan=1.0*num1/num2;
printf("he : %d\n",he);
printf("cha : %d\n",cha);
printf("ji : %d\n",ji);
printf("yu shu : %d\n",yu);
printf("shan : %f\n",shan);

}
第4个回答  2019-10-14
#include
int
main()
{
int
x=12,
y=10;
printf("x+y=%d\n",
x+y);
printf("x-y=%d\n",
x-y);
printf("x*y=%d\n",
x*y);
printf("x/y=%f\n",
x*1.0/y);
printf("x%%y=%d\n",
x%y);
return
0;
}
或者把中间的那段输出语句改成这样的也一样:
printf("x+y=%d\nx-y=%d\nx*y=%d\nx/y=%f\nx%%y=%d\n",
x+y,
x-y,
x*y,
x*1.0/y,
x%y);

如何编写程序,输入俩个整数num1和num2,计算并输出它们的的和,差,积...
int num1,num2;int n1;\/*和*\/ int n2;\/*差*\/ int n3;\/*积*\/ int n4;\/*商*\/ int n5;\/*余*\/ printf("请输入整数num1=?");scanf("%d",&num1);printf("请输入整数num2=?");scanf("%d",&num2);n1 = num1 + num2;n2 = num1 - num2;n3 = num1 * num2;n4 = num...

编写程序,输入两个整数num1和num2,计算并输出他们的和,差,积,商与余...
include<stdio.h>int main(){int num1,num2,a,b,c,d,e;scanf("num1=%dnum2=%d",&num1,&num2);\/\/输入两个数a=num1+num2;b=num1-num2;c=num1*num2;d=num1\/num2;e=num1%num2;printf("和:%d\\n差:%d\\n积:%d\\n商:%d\\n余数:%d\\n",a,b,c,d,e);return 0;} ...

编写程序,输入两个整数num1和num2,计算并输出它们的和、差、积、商和...
int pls=num1*num2;float chu=num1\/num2;int yu=num1%num2;printf("和:%d,差:%d,积:%d,商:%f,余数:&d",sum,min,pls,chu,yu);}

...是:输入两个整数num1和num2,计算并输出它们的和、差、积、商和余数...
int main(void){ int num1,num2;int x,y,z,j;float k; \/**得将k定义成实型的,即float或double型,因为除法结果有可能为小数,否则会导致错误*\/ printf("Enter num1=");\/**这一行是提醒输入数字num1,只需要引号里面的就可以了*\/ scanf("%d",&num1);printf("Enter num2="); \/...

输入2个整数 num1 和 num2,计算并输出它们的和、差、积、商与余数。
include <stdio.h> int main(){ int x=12, y=10;printf("x+y=%d\\n", x+y);printf("x-y=%d\\n", x-y);printf("x*y=%d\\n", x*y);printf("x\/y=%f\\n", x*1.0\/y);printf("x%%y=%d\\n", x%y);return 0;} 或者把中间的那段输出语句改成这样的也一样:printf("x+y=...

...输入2个整数 num1 和 num2,计算并输出它们的和、差、积、商与余数...
public class Test20010 { public static void main(String args[]) { int num1, num2;Scanner in = new Scanner(System.in);num1 = in.nextInt();num2 = in.nextInt();\/** 添加 *\/ long sum = num1 + num2;long sub = num1 - num2;long mul = num1 * num2;int div, mod...

C语言 输入两个整数,求出它们的商和余数
void main(){ int m,n;scanf("%d%d",&m,&n);int q=m\/n;int r=m-q*n;printf("%d %d",q,r);}

输入两个整数num1和num2,请你设计一个程序,计算并输出它们的和,差...
输入num1,num2,空格分开")).split(' '))num1 = int(input_data[0])num2 = int(input_data[1])print("和:" + str(num1 + num2) + ",差:" + str(num1 - num2) + ",积:" + str(num1*num2) + "商:"+ str(num1\/\/num2) + ",余数:" + str(num1%num2))

c#编写一个应用程序,根据用户输入的两个整数,分别输出者两个整数的...
题目(1)static void Main(string[] args){ Console.Write("请输入第一个整数:");int a = Convert.ToInt32(Console.ReadLine());Console.Write("请输入第二个整数:");int b = Convert.ToInt32(Console.ReadLine());Console.WriteLine("a + b:" + (a + b).ToString());Console....

用C语言编写(计算两个整数的和、 差、积、商与余数
这题主要考察对C语言输入输出的运用。代码如下:include "stdio.h"include "math.h"include "conio.h"main(){ int i,j;long a,b,c,d,e;printf("please input two numbers:\\n");scanf("%d%d",&i,&j);a=i+j;b=i*j;c=i-j;d=i\/j;e=i%j;printf("%d\\n%d\\n%d\\n%d\\n%d\\n"...

相似回答