can anyone tell me what is wrong with my code? im trying to find the sum of the first n integer value, im quite a beginner :     #include <iostream>
    using namespace std;

    int num(int n){
    for(int i= 1 ; i<=n ; i++){
    int sum=0;

    sum += i;
    cout<<sum;

    }
    }

i guess this part is clear.

    int main()
    {
    int x;
    cout<<"enter the value of x ";
    cin>>x;

    int answer=num(x);
    cout<<"the total sum of the first n integer is "<<answer;

    return 0;
    }

ive tried looking it up but no results found....
ive always had some trouble with the loops.



