0

我是这门语言的新手,所有这些溢出问题和整数类型都让我很紧张。这就是我所拥有的,但是当我运行它时,我得到了,

-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;
}

谢谢

4

4 回答 4

1

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

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;
于 2013-01-24T07:37:09.447 回答
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;
}
于 2013-01-24T07:37:01.557 回答
0

您在之后缺少分号

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

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

于 2013-01-24T07:38:05.813 回答
0

这些行产生了问题:

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

你错过了;(分号)

像这样改变它:

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

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

于 2013-01-24T07:38:39.417 回答