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

これらの行は問題を引き起こします:

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

;あなたは(セミコロン)を逃しました

次のように変更します。

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

また、操作を実行する前に、まずユーザーからの入力を読み取ります。

于 2013-01-24T07:38:39.417 に答える
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 に答える