为什么第一个 C 代码产生一个变量而第二个 C 代码产生 3 个变量。有没有办法让第一个程序稍作改动就可以工作?

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

你的计算是对的。您唯一缺少的是 20100:

之间的换行符
x= toes * 2;
printf ("%d\n", x);
/* Here----^ */
y= toes * toes;
printf ("%d\n", y);
/* And Here^ */