-4

このコードは単純に数値を取得し、これを別の数値に加算して結果を出力します。また、数値が高いか低いかも示します。これはすべてbool関数で行われます。

#include <iostream>

using namespace std;
bool addition(int num, int num2, int total);

int main()
{
    int num, num2,total;
    cout << "enter a number"<< endl;
    cin >> num;
    cout<< "enter another number" << endl;
    cin >> num2;
    addition(num, num2, total);
    {
        cout <<"the first number is:" <<  num<< " the second number is: "<< num2 <<   endl; 
        cout << "the total is: " << total << endl;
        if (1) {
            cout << "its low" ;
        } else {
            cout << "its high";
        }
        cout << endl;
    }

}

bool addition (int num, int num2, int total) {
    //total = 0;
    total = num + num2;
    if (total >= 10){
        return 1;
    } else { 
        return -1;
    }
}

問題は、このプログラムが常に数が少なく、合計が常に 32767 であると言っているということです。理由はわかりません。

4

4 に答える 4