I'm having trouble on how to calculate the sum while outputting the total end result as 1+2+3+4+5=sum. How can I output both correctly using for loops?
main()
{
int num, i, sum;
cout<<"Input a number -> ";
cin>>num;
for(i=1;i<=num;i++)
{
cout<<i<<" + ";
}
}