Write a loop to print the first 10 powers of 3, namely 30 = 1, 31 = 3, 32 = 9, …, 39 = 19683.
language is c++
Don't use plagiarized sources. Get Your Custom Essay on
Answered! Write a loop to print the first 10 powers of 3, namely 30 = 1, 31 = 3, 32 = 9, …, 39 = 19683. language is c++…
GET AN ESSAY WRITTEN FOR YOU FROM AS LOW AS $13/PAGE
Expert Answer
Here is the code and output for hte question. Please don’t forget to rate the answer if it helped. Thank you very much.
#include <iostream>
using namespace std;
int main()
{
int power = 1;
for(int i = 0; i < 10; i++) //loop through 0-9
{
cout<< “3^” << i << ” = ” << power <<endl;
power *= 3;//mulitply by 3 to get next number
}
}
output
3^0 = 1
3^1 = 3
3^2 = 9
3^3 = 27
3^4 = 81
3^5 = 243
3^6 = 729
3^7 = 2187
3^8 = 6561
3^9 = 19683