返回列表 發帖

004_變數宣告與輸出

宣告變數a是整數型態、b浮點數、c字元、d字串,內容自訂接著輸出四個變數如下:
  1. a = 55
  2. b = 159.6
  3. c = Z
  4. d = Hello
複製代碼

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.         int a = 55;
  7.         float b =159.6;
  8.         char c = 'z';
  9.         string d = "hello";
  10.         
  11.     cout<<"a ="<<a<<endl;
  12.       
  13.         cout<<"b ="<<b<<endl;
  14.       
  15.         cout<<"c ="<<c<<endl;
  16.         
  17.          cout<<"d ="<<d<<endl;
  18.         
  19.         
  20.         system("pause");
  21.         return 0;
  22. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>

  3. using namespace std;

  4. int main()
  5. {
  6.         int a = 55;
  7.         float b = 159.6;
  8.         char c = 'Z';
  9.         string d = "Hello";
  10.        
  11.     cout << "a =" << a << endl;
  12.         cout << "b =" << b << endl;
  13.         cout << "c =" << c << endl;
  14.         cout << "d =" << d << endl;
  15.        
  16.        
  17.         system("pause");
  18.         return 0;
  19. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;

  4. int main()
  5. {
  6.         int a =55;
  7.         float b =159.6;
  8.         char c = 'Z';
  9.         string d = "Hello";
  10.        
  11.         cout << " a = " << a << endl;
  12.         cout << " b = " << b << endl;
  13.         cout << " c = " << c << endl;
  14.         cout << " d = " << d << endl;
  15.        
  16.         system("pause");
  17.         return 0;
  18. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.         int a = 55;
  7.         float b =159.6;
  8.         char c = 'z';
  9.         string d = "hello";
  10.        
  11.         cout << "a=" << a << endl;               
  12.         cout << "b=" << b << endl;
  13.         cout << "c=" << c << endl;
  14.         cout << "d=" << d << endl;
  15.         system("pause");
  16.         return 0;
  17. }
複製代碼

TOP

返回列表