Search This Blog

Friday, 21 August 2020

Formula of addition of number of terms

 #include<iostream>

using namespace std;

int main()

{

int n ,a,d,sum;

cout<<"enter the value of a"<<endl;

cin>>a;

cout<<"enter the vlaue of d"<<endl;

cin>>d;

cout<<"enter the value of n"<<endl;

cin>>n;

sum=(n)/(2)*((2*a)+(n-1)*(d));

 

cout<<"sum="<<sum;

return 0;

}


No comments:

Post a Comment

Search This Blog

Contact Form

Name

Email *

Message *

Popular Posts