Here is the question: Write a function which accepts an integer N and returns the sum of first N numbers.

and here are my codes:

int Myfun(int x);
int main()
    int a, sum;
    printf("Enter an integer: ");
    scanf("%d", &a);

    printf("sum is %d\n", sum);

    return (1);

int Myfun(int x)
    int a, count, sum=0;


       return (sum);


The problem here is i do not get the correct output. If i enter 4 it should have give the output 10 but it gives a 0. I need help if there are missing codes are any mistake help me.

main() is not calling MyFunc(). You need to add a call to that function between lines 8 and 10.

MyFunc() doesn't use the paramter x in the loop on line 20. Sould be: count <= x