This Blog is dedicated to Sir Johnson Lin
Learn flow chart from C language , master C with the chart!

C++ 基本 使用迴圈決策功能 C++ basic function , loop decision (while) introduction



D:\cppCodes\HelloWhile\HelloWhile.c++
 1 //++++++++++++++++++++++++++
 2  //      HelloWhile.cpp
 3  //++++++++++++++++++++++++++
 4  
 5  ///#include headers
 6  #include <iostream>
 7  
 8  ///USING
 9  using namespace std;
10  
11  ///mainentry
12  int main()
13  {
14      ///declare variables
15      int iMyInt = 88;               // Integer
16      float fMyFloat = 1.68;    // Floating point number
17      char cMyChar = 'A';         // Character
18      string sMyString = "my text string ";     // txt string
19      char caMyString[] = "my character array"; // txt string 
20      
21      ///initial condition
22      int i=1;
23      
24      ///loop till over max
25      while (i <= 3)
26      {
27          ///Display variables
28          cout << "Int = " << iMyInt << endl;
29          cout << "Float = " << fMyFloat << endl;
30          cout << "Char = " << cMyChar << endl;
31          cout << "String = " << sMyString << endl;
32          cout << "CharArray = " << caMyString << endl;
33          
34          ///update condition
35          i++;
36          
37          ///+
38      }//end while
39      
40      ///mainend
41      return 0;
42  }//end main()
43  

@ 下載程式碼 Download source code

沒有留言:

張貼留言