要使用者輸入一個整數/浮點數/字符,並印出結果

#include <iostream>
#include <cstdlib> 
using  namespace std;
int main()
{
    int  i;
    double  d;
    char c;
    
    cout << "請輸入一個整數(像是 1,2, 100)\n";
    cin >> i;

    cout << "請輸入一個浮點數(比如說 3.14)\n";
    cin >> d;
    
    cout << "請輸入一個字符(可以是 a,A,7)\n";
    cin >> c;
    
    cout << "你輸入的整數是" << i <<"\n";   
    cout << "你輸入的浮點數是" << d <<"\n"; 
    cout << "你輸入的字符是" << c <<"\n";         
    system("pause");
    return 0;
}

留言