#include<iostream>
using namespace std;
int anik(int a)
{
if(a == 1)
return 1;
else
return a + anik(a-1);
}
int main()
{
int n;
cout << "Enter A Number :: ";
cin >> n;
cout << endl;
cout << "Sum of 1 to " << n << " :: " << anik(n) << endl;
return 0;
}
using namespace std;
int anik(int a)
{
if(a == 1)
return 1;
else
return a + anik(a-1);
}
int main()
{
int n;
cout << "Enter A Number :: ";
cin >> n;
cout << endl;
cout << "Sum of 1 to " << n << " :: " << anik(n) << endl;
return 0;
}
Comments
Post a Comment