Hello all,
I have done with this code
Output :
Enter n = 5
2+4+6+8+10 = 30
I compile with Turbo C++, version 3
here is my code
#include <iostream.h>
#include <conio.h>
void main() {
clrscr();
int n, sum=0;
cout<<"Enter n= "; cin>>n;
for (int i=1; i<=n; i++) {
cout<<2*i<<"+";
sum = sum + i;
}
cout<<"\b\b ="<<sum;
getch();
}
--------------------------
By the way, could you help me if I want to have output like this
Enter n =5
2-4+6-8+10 = ....
Thanks in advance,