i want to find out addotion of numbers from n to 1;(but this programme doesnot work)
#include <iostream>
using namespace std;
int sum (int);
int main()
{
int x;
cin>>x;
sum (x);
}
int sum (int n){
if (n==1)
{return 1;}
else
{return n+sum(n-1);}
}
in the main function
you need to print the result by using cout command.
cout << sum(x);
please mark it as a solved problem