Write a program in C++ to display the n terms of even natural number and their sum. .


#include <iostream>
using namespace std;
void main()
{
int i,n,sum=0;

   cout<<"Input number of terms : ";
   cin>>n;
   cout<<"The even numbers are :";
   for(i=1;i<=n;i++)
   {
     cout<<2*i;
     sum+=2*i;
   }
   cout<<endl;
   cout<<"The Sum of even Natural Number upto "<<n<<" is = "<<sum<<endl;

       system ("pause");
}
Write a program in C++ to display the n terms of even natural number and their sum. . Write a program in C++ to display the n terms of even natural number and their sum. . Reviewed by Unknown on May 18, 2017 Rating: 5

No comments:

Powered by Blogger.