#include <iostream>
using namespace std;
int getsum(int);
int main() {
int num, sum;
cin >> num;
sum = getsum(num);
cout << "sum " << sum << endl;
}
int getsum(int value) {
int sum = 0;
sum += value;
return sum;
}
In this code, the variable value is declared in the function getsum, but the value has not been initialized to any value, so can I write a code called sum+=value
?
The value is a parameter that receives the factor num, so it receives the value of num. For example, if you put 1 in num and getsum(num), the value is 1.
© 2024 OneMinuteCode. All rights reserved.