WAP C++ to 2+4+6+8+............+n
#include <iostream>
using namespace std;
int main()
{
int n=0,a=2;
cout<<"enter the limit";
cin>>n;
for(int i=1;i<=n;i++){
cout<<a;
a=a+2;
if(i<n)
cout<<"+";
}
return 0;
}
Output:-
enter the limit 5
2+4+6+8+10