1 //++++++++++++++++++++++++++
2 // HelloFor.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 ///for loop (thrice)
22 for (int i = 1; i <= 3; i++)
23 {
24 ///Display variables
25 cout << "Int = " << iMyInt << endl;
26 cout << "Float = " << fMyFloat << endl;
27 cout << "Char = " << cMyChar << endl;
28 cout << "String = " << sMyString << endl;
29 cout << "CharArray = " << caMyString << endl;
30
31 ///+
32 }//end for
33
34 ///mainend
35 return 0;
36 }//end main()
37
This Blog is dedicated to Sir Johnson Lin
C++ 基本 使用迴圈決策功能 C++ basic function , loop decision (for) introduction
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言