c語言中循環控制語句(do語句)


 

1、

do + 循環體 + while語句;當while語句不為0時,會繼續循環,當while語句為0時,跳出循環。

#include <stdio.h>

int main(void) { int i, j; ##(僅在循環體使用的變量要在復合語句(程序塊)中進行聲明。???) do { puts("please input the i value:"); printf("i = "); scanf("%d", &i); if (i % 2) puts("odd"); else puts("even"); puts("please input the j value, 0: continue; other: quit."); printf("j = "); scanf("%d", &j); } while (j == 0); ## 當 while語句不為0時,會繼續循環,即j等於0時會繼續循環; 當while語句為0是,即j不等於0時會跳出循環。 return 0; } 

 

 


免責聲明!

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



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