In: Computer Science
powers: Write a program to display the following table with headings and totals. You must use variables to represent all quantities and a for loop for repetition.
x x^2 x^3
11 121 1331
14 196 2744
17 289 4913
20 400 8000
23 529 12167
26 676 17576
29 841 24389
32 1024 32768
35 1225 42875
38 1444 54872
Totals: 245 6745 201635
//Comment me if you want any changes below is the link to the code
// link : https://repl.it/@FAYAZPASHA/EmbellishedCarelessDeals#main.cpp
#include<bits/stdc++.h>
using namespace std;
int main(){
cout << "x\tx^2\tx^3\n";
int x = 11; // declaring my variables
int a = 0; // a, b, c just to maintain the sum
int b = 0;
int c = 0;
for(; x < 39; x += 3){
a += x; // summing the values
b += (x * x);
c += (x * x * x);
cout << x << "\t"
<< x * x << "\t" << x * x * x <<
endl;
}
cout << "Totals : ";
cout << a << "\t" << b << "\t"
<< c << endl; // printing the totals
return 0;
}