fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cmath>
  4. using namespace std;
  5.  
  6. main()
  7.  
  8. {
  9. int v1=pow(2,31)-1;
  10. short v2=pow(2,15)-1;
  11. char v3='A';
  12. bool v4=true;
  13. float v5=exp (1);
  14. double v6=exp(1);
  15. cout<<"各種資料型態之變數宣告,其輸出結果如下:\n";
  16. cout<<"變數 v1 宣告為 int 整數型態、其值 = "<<v1<<endl;
  17. cout<<"變數 v2 宣告為 short 整數型態、其值 = "<<v2<<endl;
  18. cout<<"變數 v3 宣告為 char 整數型態、其值 = "<<v3<<endl;
  19. cout<<"變數 v4 宣告為 bool 整數型態、其值 = "<<v4<<endl;
  20. cout<<"變數 v5 宣告為 float 整數型態、其值 = "<<v5<<endl;
  21. cout.precision(16);
  22. cout<<"變數 v6 宣告為 double 整數型態、其值 = "<<v6<<endl;
  23. system("Pause");
  24. }
Success #stdin #stdout #stderr 0.01s 5324KB
stdin
Standard input is empty
stdout
各種資料型態之變數宣告,其輸出結果如下:
變數 v1  宣告為 int 整數型態、其值 = 2147483647
變數 v2  宣告為 short 整數型態、其值 = 32767
變數 v3  宣告為 char 整數型態、其值 = A
變數 v4  宣告為 bool 整數型態、其值 = 1
變數 v5  宣告為 float 整數型態、其值 = 2.71828
變數 v6  宣告為 double 整數型態、其值 = 2.718281828459045
stderr
sh: 1: Pause: not found