请问一下我哪里出错了,c语言编写 5
/*Program2.5Calculationswithcookies*/#include<stdio.h>intmain(void){intcookies=5;intc...
/*Program 2.5 Calculations with cookies*/
#include<stdio.h>
int main(void)
{
int cookies = 5;
int cookie_calories = 125; //Calories per cookie
int total_eaton = 0; //Total cookies eaten
int eaten = 2;
cookies = cookies - eaten; //Subtract number eaten from cookies
total_eaten = total_eaten + eaten;
printf("\nI have %d cookies. There are %d cookies left", eaten, cookies);
//New value for cookies eaten
eaten = 3; //Subtract number eaten from cookies
cookies = cookies - eaten;
total_eaten = total_eaten + eaten;
printf("\nI have eaten %d more. Now there are %d cookies left\n", eaten, cookies);
printf("\nTotal energy consumed is %d calcries.\n", total_eaten*cookie_calories);
return 0;
}
编译的时候说total_eaten = total_eaten + eaten; 这个undeclared
可是我看好像没有啥不对的呀
哦,抱歉,我知道了,麻蛋....低级错误
打错字母了orz 展开
#include<stdio.h>
int main(void)
{
int cookies = 5;
int cookie_calories = 125; //Calories per cookie
int total_eaton = 0; //Total cookies eaten
int eaten = 2;
cookies = cookies - eaten; //Subtract number eaten from cookies
total_eaten = total_eaten + eaten;
printf("\nI have %d cookies. There are %d cookies left", eaten, cookies);
//New value for cookies eaten
eaten = 3; //Subtract number eaten from cookies
cookies = cookies - eaten;
total_eaten = total_eaten + eaten;
printf("\nI have eaten %d more. Now there are %d cookies left\n", eaten, cookies);
printf("\nTotal energy consumed is %d calcries.\n", total_eaten*cookie_calories);
return 0;
}
编译的时候说total_eaten = total_eaten + eaten; 这个undeclared
可是我看好像没有啥不对的呀
哦,抱歉,我知道了,麻蛋....低级错误
打错字母了orz 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询