编写一个程序,用C语言打印两个输入整数的和、积和商

编写一个程序,用C语言打印两个输入整数的和、积和商,c,compiler-errors,C,Compiler Errors,我对这门语言还不熟悉,所有这些溢出问题和整数类型都让我很紧张。这是我所拥有的但当我运行它时 -bash: syntax error near unexpected token `newline' 守则: #include <stdio.h> int main(void) { int one, two, s, q, m; s = one+two q = one/two m = one*two printf("Enter first positive in

我对这门语言还不熟悉,所有这些溢出问题和整数类型都让我很紧张。这是我所拥有的但当我运行它时

-bash: syntax error near unexpected token `newline'
守则:

#include <stdio.h>
int main(void)
{
   int one, two, s, q, m;
   s = one+two
   q = one/two
   m = one*two
   printf("Enter first positive integer: ");
   scanf("%d", &one);
   printf("Enter second positive integer: ");
   scanf("%d", &two);
   printf("The addition of %d and %d is %d", one, two, s);
   printf("The integer division of %d divided by %d is %d", one, two, q);
   printf("the multiplication of %d and %d is %d", &one, &two, m);
   return 0;
}
#包括
内部主(空)
{
int一,二,s,q,m;
s=1+2
q=1/2
m=1*2
printf(“输入第一个正整数:”);
scanf(“%d”和一);
printf(“输入第二个正整数:”);
scanf(“%d”和两个);
printf(“加上%d和%d就是%d”,一、二、s);
printf(“将%d除以%d的整数除法是%d”,一,二,q);
printf(“%d和%d的乘积是%d”、&1、&2,m);
返回0;
}
谢谢

试试这个:

#include <stdio.h>
int main(void)
{
int one, two;
printf("Enter first positive integer: ");
scanf("%d", &one);
printf("Enter second positive integer: ");
scanf("%d", &two);
printf("The addition of %d and %d is %d", one, two, (one+two));
printf("The integer division of %d divided by %d is %d", one, two, (one/two));
printf("the multiplication of %d and %d is %d", &one, &two, (one*two));
return 0;
}
#包括
内部主(空)
{
int一,二;
printf(“输入第一个正整数:”);
scanf(“%d”和一);
printf(“输入第二个正整数:”);
scanf(“%d”和两个);
printf(“加上%d和%d就是%d”,一,二,(一加二));
printf(“将%d除以%d的整数除法是%d”,一,二,(一/二));
printf(“%d和%d的乘积是%d”、&1、&2,(1*2));
返回0;
}

您应该在获得输入后执行计算

printf("Enter first positive integer: ");
scanf("%d", &one);
printf("Enter second positive integer: ");
scanf("%d", &two);

s = one+two;
q = one/two;
m = one*two;

您缺少后面的分号

   s = one+two
   q = one/two
   m = one*two

另外,您应该在读取输入后执行计算,但这是另一个问题。

这些行产生了问题:

s = one+two
q = one/two
m = one*two
你错过了
(分号)

将其更改为:

s = one+two;
q = one/two;
m = one*two;

在执行操作之前,也要先读取用户的输入。

如果您有分号,还必须获取
one
two的值。
@BlackHatShadow:是的,但这并不是阻止他首先编译的问题。@BlackHatShadow:那么您的答案在逻辑上也是不正确的。若第二个数字是零,那个么除法将是零fail@Mindhun,你读过我的答案和我写评论的时候的评论了吗?即使你有分号,程序仍然需要询问
one
two
@BlackHatShadow:的值,以回答OP遇到的问题。更正整个代码不是我的工作。我只是给你一个线索problem@MindhunMP,我理解你的意思,但你回答问题的方式可能会导致另一个问题。还有一件事,你必须检查你的
2
是否是
0
中的
0
你确实编译了这段代码,不是吗?这修复了它,谢谢!分号并不是真正的问题,只是我在这里复制/粘贴代码的方式使它们不会错误地出现。我在运行程序时遇到了问题,linux很混乱!