如果条件plz解释我这个代码,那么分号是正确的 [英] semicolon is put right after if condition plz explain me this code
本文介绍了如果条件plz解释我这个代码,那么分号是正确的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是C语言代码,如果条件plz解释我这段代码,则分号被放在右边。
this is C Language code where the semicolon is put right after if condition plz explain me this code.
#include<stdio.h>
int main()
{
int x = 10, y = 100%90, i;
for(i=1; i<10; i++)
if(x != y);
printf("x = %d y = %d\n", x, y);
return 0;
}
推荐答案
这样的代码虽然有效但没有意义。
它检查十如果x
与y
不同,并且如果条件满足(实际上不满足)则没有(到期)在if语句之后的分号:这样的分号是''空语句'')。
Such code, albeit valid, make no sense.
It checks ten times ifx
is different fromy
and if the condition is satisfied (actually it is NOT satisfied) does NOTHING (due to the semicolon after the if statement: such a semicolon is the ''empty statement'').
这篇关于如果条件plz解释我这个代码,那么分号是正确的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文