Hello guys, I just join your site to get help about my coding programme class c++. I do have to modify my programme that the out put will show the form sum=1+3+5+7=16. Can you please help me out thxx .
Programme is adding odd integer :
# include <iostream>
using namespace std;
int main ()
{
int n=0;
int counter=0;
int sum=0;
cout<<"Please enter the value of n"<<endl;
cin>>n;
counter=1;
while(counter<=n)
{
sum=sum+(2*counter-1);
counter++;
}
cout<<"the sum is"<<sum<<endl;
return 0;
}