执行此段时I,x和y的输出是多少 [英] What is the output of I, x, and y upon execution of this segment

查看:58
本文介绍了执行此段时I,x和y的输出是多少的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

int i = 0;
int x = 0;
int y;

while(i<3){
  x = x+5;
  i++;}











[edit : gjl - reformatted]

int i = 0;
int x = 0;
int y;

while (i<3)
{
  x = x+5;
  i++;
}





[/ edit]



我尝试过:



尝试使用多种语言通过repl.it运行。通过while继续接收错误。



[/edit]

What I have tried:

Have tried running this through repl.it with many different languages. Continually receiving error on line with "while".

推荐答案

尝试评论y的声明。它似乎未被使用,并且可能导致某些编译器处于高警告级别时出错。
Try commenting off the declaration of y. It appears to be unused and that can result in an error with certain compilers at a high warning level.


Quote:

在while的情况下继续接收错误。

Continually receiving error on line with "while".



错误消息告诉您某些内容,并且有些内容旨在帮助您了解出现了什么问题。你只是忘了告诉我们错误信息。




The error message tells you something and that something is aimed to help you understand what is going wrong. You just forgot to tell us the error message.

Quote:

y = 2



建议:不要随机给出答案,程序中没有魔法,如果是变量值,有原因,有逻辑的。



我们不做你的家庭工作。

HomeWork不会在乞求别人做你的工作时测试你的技能,它会让你思考和帮助您的老师检查您对所学课程的理解,以及您应用这些课程时遇到的问题。

你的任何失败都会帮助你的老师发现你的弱点并设定补救措施。

所以,试一试,重读你的课程并开始工作。如果您遇到特定问题,请显示您的代码并解释这个确切的问题,我们可能会提供帮助。



如果您不满意不能得到您想要的答案,请考虑关于这个:

只要给你答案,就像试着通过让别人为你训练驾驶汽车,它不起作用。


Advice: do not give random answers, there is not magic in a program, if a variable value, there is a reason, a logical one.

We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help.

If you are unhappy not getting the answer you want, think about this:
Just giving you the answer would be like trying to learn drive a car by having someone else trained for you, it don't work.


这篇关于执行此段时I,x和y的输出是多少的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆