write a program to display the terms and sum of following series-1+4+7+10+13+16+19+22-in c++ program
Attachments:
Answers
Answered by
4
Question::
Write a program to display the terms and sum of following series::
1+4+7+10+13+16+19+22
in a C++ program.
Answer::
#include <iostream>
using namespace std;
int main() {
cout << "1 + 4 + 7 + 10 + 13 + 16 + 19 + 22 = " << 1 + 4 + 7 + 10 + 13 + 16 + 19 + 22 << endl;
return 0;
}
Logic::
==> We declared adding iostream header file on line 1.
==> We used standard namespace and declared that on line 2.
==> 3rd line is a whitespace which is ignored by C++.
==> 4th line had the int main function which is necesarry in almost every program.
concatenated two strings in which one is our required output.
necessary at the end f every C++ program.
I hope that my answer helped you....
Answered by
0
Answer:
dhsnwijjdieiwmkssiskia
Similar questions