C++ Program for Printing Sum of Numbers till N

 #include<iostream>

using namespace std;

int main()

{

int i ,n ,s=0, t=0;

cout<<"Printing sum of numbers till N: ";

cin>>n;

i=1;

while(i<=n)

{

cout<<i<<" + ";

s=s+i;

t+=s;

i++;

}

cout<<"\b\b = "<<s<<endl;

}

Comments