Data types in 2_c languages (10) while, for

Source: Internet
Author: User

1 Loop Statement 1.1 while

while (condition), if the condition is true, the loop continues, the condition is false, and the loop ends

while (1), the notation of the dead loop

1.2 Continue

The loop encounters the continue statement, no longer executes the continue code below, but instead returns to the loop start statement and resumes execution of the loop

1.3 Break

Loop encounters break statement, immediate terminal loop, Loop end

1.4 Do While

Do

Compound statement

while (condition);

For do, the compound statement of the loop can be executed at least once

For while, it is possible that the compound statement will not have a single execution opportunity

1.5 for

for (int I = 0;i<10;i++)

1.6 Loop nesting

int i,j;

for (i = 9; i > 0; i--)

{

for (j = 9; j > 0; j--)

{

printf ("%d\t", I * j);

}

printf ("\ n");

}

#include <stdio.h>intMain01 (void){    inti =1; //While (1)//shu phenomena?     while(1) {scanf ("%d", &i); printf ("Hello world!\n"); } printf ("end\n"); return 0;}intmain02 () {inti =0;  while(1) {printf ("Please input i:"); scanf ("%d", &i); if(i = =9)            Continue;//Continuc Fax锛 Argon à village surprise phenomena Å è¡#̈亞 ョ draft 鎺 ュ WUCUN arrival plate Fright phenomena Crypto Liao?        if(i = =6)             Break;//Break Fax锛 Argon à Village surprise phenomena 粓 Վ 紝 é € credential coax surprise phenomena?printf"i =%d\n", i); }    return 0;}intmain03 () {inti =0;  Do{printf ("Please input i:"); scanf ("%d", &i); printf ("i =%d\n", i); } while(i); return 0;}intmain04 () {inti =0; //1 à 佸 å gallium цi = 0 锛 toric bang battling dress Juan 猣 or Atlas environment 锛 trickle € Shu ュ hongyu Gallium parameters Juan € Rao? //2 à 佸 垽 à 璱 display Surprising hao younger generation Å 10 锛 toric 鏋 Shibuya hao younger generation Å 10 锛 岄 偅 cen 堝 surprise phenomena household called 紝 Å ﹀ Spain Atlas environment Juan 柇//3 à 乮 + 锛 Juan € Rao ℃ 墽 Aachen 宖 or fermium ecf 椂 necklace 欙 紝 Juan interacted 墽 Aachen history + +//For (i = 0; i<10; i++)//    {    //if (i = = 5)//continue; //printf ("i =%d\n", i); //    }I=0;  while(I <Ten)    {        if(i = =5) {i++; Continue; } printf ("i =%d\n", i); I++; }    return 0;}intMain05 ()//necklace 掔 Xinjiang fermium? 9 Aachen?{    inti,j;  for(i =9; i >0; i--)    {         for(j =9; J >0; j--) {printf ("%d\t"Ij); } printf ("\ n"); }    return 0;}intmain06 () {intI, J;  for(i =0; i<Ten; i++)    {         for(j =0; J < I; J + +) {printf ("*"); } printf ("\ n"); }    return 0;}intMain07 ()//Gallium name 嵃 Shu D 笁 Birkenau?{    intI, J; intsum =0;  while(1) {printf ("Please input sum:"); scanf ("%d", &sum); if(Sum <2)             Break;  for(i =1; i < sum; i++)        {             for(j =1; J < Sum-i; J + +) {printf (" "); }//Fork name downloading the shortage bake characters fermium?             for(j =0; J < (I *2-1); J + +) {printf ("*"); }//cha name downloading * å è¡#̈亞 wind cryptoprintf"\ n"); }    }    return 0;}intMain ()//Shu D 笁?{    intI, J; intsum =0;  while(1) {printf ("Please input sum:"); scanf ("%d", &sum); if(Sum <2)             Break;  for(i =1; i < sum; i++)        {             for(j =1; J < I; J + +) {printf (" "); }             for(j =0; J < ((sum-i) *2-1); J + +) printf ("*"); printf ("\ n"); }    }    return 0;}

Source: Intelligence Podcast for study only

Data types in 2_c languages (10) while, for

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.