[求助]函数问题
下面的东西中红色的部分谁能帮我解释一下,我不懂,谢谢!
#include <iostream>
using namespace std;
int triangle(int num);
int main() {
int n;
cout << "Enter a number and press ENTER: ";
cin >> n;
cout << "Function returned " << triangle(n);
return 0;
}
int triangle(int n) {
int i;
int sum = 0;
for (i = 1; i <= n; i++)
sum = sum + i;
return sum;
}