Answer to Question #34908 in C++ for Muldir

Question #34908
Write a program that calculates element of sequence by its index if given first and second elements of arithmetic sequence.Input first, second elements of sequence and index:
1 5 3
1
Expert's answer
2013-09-10T11:06:24-0400
#include <cstdlib>
#include <iostream>


using namespace std;


int main()
{
int a,b,n;
cin>>a>>b>>n;
cout<<a+(n-1)*(b-a)<<endl;
cin.get();
cin.get();
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS