SOURCE CODE OUTPUT
#include<iostream>
using namespace std;
int main()
{
long num,sum=2;
cout<<"enter the number ";
cin>>num;
cout<<"2";
for(int i=3;i<=num;i++)
{
if(i%2==0)
{
cout<<"+"<<i;
sum+=i;
}
}
cout<<" = "<<sum;
return 0;
}
using namespace std;
int main()
{
long num,sum=2;
cout<<"enter the number ";
cin>>num;
cout<<"2";
for(int i=3;i<=num;i++)
{
if(i%2==0)
{
cout<<"+"<<i;
sum+=i;
}
}
cout<<" = "<<sum;
return 0;
}
Any questions regarding to program please write in comments.
No comments:
Post a Comment