C++ Program to Calculate Sum of Natural Numbers. we make Some Program in C++ program to Find Sum of Natural Numbers using Recursion.Lets Try To make it.
C++ program to Find Sum of Natural Numbers
#include<iostream> #include<conio.h> using namespace std; int main() { int i,n,sum=0; cout<<"Enter Any Numbers : "; cin>>n; for(i=1;i<=n;++i) { sum+=i; } cout<<"Sum="<<sum; return 0; }
Output of Program
Enter a positive integer: 50 Sum = 1275