[英]Why does the 1st C code result in one variable and the 2nd in 3 variables. Is there a way to make the first program work by slight changes?
誰能幫助理解為什么我的結果是 20100 而第二個結果是 3 個值,因為它應該幫助我完成未來的項目? 我是編程和 C 的新手。
我的版本
#include <stdio.h>
int main (void)
{
int toes
toes = 10;
int x,y;
x= toes * 2;
printf ("%d", x);
y= toes * toes;
printf ("%d", y);
}
正確的版本:
#include <stdio.h>
int main(void)
{
int toes;
toes = 10;
printf("toes = %d\n", toes);
printf("Twice toes = %d\n", 2 * toes);
printf("toes squared = %d\n", toes * toes);
return 0;
}
你的計算是對的。 您唯一缺少的是分隔20
和100
的換行符:
x= toes * 2;
printf ("%d\n", x);
/* Here----^ */
y= toes * toes;
printf ("%d\n", y);
/* And Here^ */
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.