1. Function problem (recursion)

I want to calculate the formula : 1+2+3+4+............+n = n (n+1)/2. anyone will help me to find the error of the program? it just show an error result ........

Code:
```// Function (RECURSION)

# include<stdio.h>

int funct1(int n);

void main()

{
int n,t;
printf("Enter the value until which you want to sum up\n");
scanf("%n", &n);

t= funct1(n);

printf("  summation= %d", t );

}

int funct1(int n)

{

if (n>0)

return (n+ funct1(n-1));

}```

2. According to the scanf docs there's no such specifier as "%n". There are different ones to use depending on exactly what you need, the documentation describes them all.

scanf - C++ Reference

There's no 'bottom case' (can't remember what it's called) for your recursive function. You need to specify something to return for when it does get to zero.

3. Every thing is ok.other than the '%n' in the scanf .You have to use '%d' is it .

Code:
```  # include<stdio.h>

int funct1(int n);

int main()
{
int n,t;
printf("Enter the value until which you want to sum up\n");
scanf("%d", &n);

t= funct1(n);

printf("  summation= %d", t );

}

int funct1(int n)

{

if (n>0)

return (n+ funct1(n-1));

}```

4. You forget base case.
Code:
```int funct1(int n)
{
if(n > 0)
return n + funct1(n-1);
return 0;
}```
Btw, do you enable compiler warning?

5. DeadPlanet, karthigayan and Bayint Naung @ its working now . thank you all .