Arithmetic series in mathematics is a sequence of numbers where the next number is the previous number with the addition of a number is a specific difference. Examples are 3,5,7,9,11,13, ..... Arithmetic series can be expressed by the following formula:
a, a + b, a + 2b, a + 3b, ...
• Print Series Arithmetic Algorithms
cetak_aritmatika procedure (input / output x: array, input: a, input: b, input: n)
Declaration:
i: integer
Description:
read a, b, n
x [1] <= a
x [2] <= a + b
for i = 3 to n do
x [i] <= a + (b * i)
end for
for i = 1 to n do
write x [i]
end for
• Algorithm Finding nth
suku_n procedure (input: a, input: b, input: n, output: un)
Declaration:
a, b, n, un: Integer
Description:
read a, b, n
un <= a + (n-1) * b
write un
• Finding Algorithm amount of all ethnic
jumlah_n procedure (input: a, input: b, input: n, output: sn)
Declaration:
a, b, n, sn: integer
Description:
read a, b, n
sn <= (n / 2) * (2 * a + (n-1) * b)
write sn
Program Runs Arithmetic
a, a + b, a + 2b, a + 3b, ...
• Print Series Arithmetic Algorithms
cetak_aritmatika procedure (input / output x: array, input: a, input: b, input: n)
Declaration:
i: integer
Description:
read a, b, n
x [1] <= a
x [2] <= a + b
for i = 3 to n do
x [i] <= a + (b * i)
end for
for i = 1 to n do
write x [i]
end for
• Algorithm Finding nth
suku_n procedure (input: a, input: b, input: n, output: un)
Declaration:
a, b, n, un: Integer
Description:
read a, b, n
un <= a + (n-1) * b
write un
• Finding Algorithm amount of all ethnic
jumlah_n procedure (input: a, input: b, input: n, output: sn)
Declaration:
a, b, n, sn: integer
Description:
read a, b, n
sn <= (n / 2) * (2 * a + (n-1) * b)
write sn
Program Runs Arithmetic
# Include <cstdlib>
# Include <iostream>
using namespace std;
arithmetic class {
friend istream & operator>> (istream &, arithmetic &);
friend ostream & operator <<(ostream &, arithmetic &);
public:
arithmetic ();
void print ();
void interest ();
void sum ();
private:
int x [100];
int a, b, n, un, sn;
};
istream & operator>> (istream & mlebu, arithmetic & s) {
court <<"Enter Interest First:"; mlebu>> S.A;
court <<"Enter the difference:"; mlebu>> s.b;
court <<"Enter the Number of Interest:"; mlebu>> sn; court <<endl;
mlebu return;
}
ostream & operator <<(ostream & metu, arithmetic & v) {
metu <<"Interest First:" <<v.a <<endl;
metu <<"Difference:" <<v.b <<endl;
metu <<"Number of Interest:" <<v.n <<endl;
metu <<"Arithmetic Series:";
for (int i = 0; i <v.n; i + +) {
metu <<v.x [i ]<<",";}
metu <<endl;
metu <<"Number of Interest The n:" <<v.un <<endl;
metu <<"Number of All Tribes:" <<v.sn <<endl;
metu return;}
arithmetic: arithmetic () {
court <<"\ t \ tSlamet Icelandic Al Hidayah" <<endl;
court <<"\ t \ t 10018075" <<endl;
court <<endl;
court <<"PRINTING AND COUNTING PROGRAM RUNS Arithmetic" <<endl;
court <<endl;
}
void arithmetic:: print () {
x [0] = a;
x [1] = a + b;
for (int i = 2; i <n; i + +) {
x [i] = a + (b * i);}
}
void arithmetic:: tribe () {
int t;
court <<"Enter Interest Want In looking for:"; cin>> t;
un = a + (t-1) * b;}
void arithmetic:: sum () {
sn = (n / 2) * (2 * a + (n-1) * b);}
int main (int argc, char * argv [])
{
arithmetic x;
cin>> x;
x.cetak ();
x.suku ();
x.jumlah ();
court <<x;
court <<endl;
system ("PAUSE");
return EXIT_SUCCESS;
}
Output :
Well that's the program that I can make,,,,,!
If there are less jelass know any mistake, do not hesitate to leave a comment ataun advice. So that I can fix it later terimakasihh over his visit,,
Regards super ..
0 Response to " ARITHMETIC SERIES PROGRAM IN C + + "
Post a Comment