while 語句判斷條件


1While(0) 里邊判斷條件為0或非0, 0為假終止,非0為真執行循環體。

2. While語句中的循環體是用;結束,跟是否加{}無關

例如1:

#include <stdio.h>
int main()
{
 int i = 5;
 int p = 0;
 while (i--)
 {
  printf("%d\n", i);
 }
 printf("%d\n", i);
}
則輸出為

 

2. 

#include <stdio.h>
int main()
{
 int i = 5;
 int p = 0;
 while (i--);
 {
  printf("%d\n", i);
 }
 printf("%d\n", i);
}

 

 

#include <stdio.h>
int main()
{
 int i = 5;
 int p = 0;
 while (i--)
 printf("%d\n", i);
 printf("%d\n", i);
}

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM