Friday, June 4, 2021

program make a series and calculate the sum (POP) (139)

#include<iostream>

using namespace std;

int main()

{

     int i,n,t=1;

int sum=0;

cout<<"please enter the number of series:";

     cin>>n;

for(i=1; i<=n; i++)

{

sum=sum+t;

cout<<t;

    t=t*10+1;

cout<<endl;

}

cout<<"the sum is:"<<sum;

} 

No comments:

Post a Comment