Question: Using C programming to create your own function called power3. The function must take 1 argument and return the power base three value. power3 function

Using C programming to create your own function called "power3". The function must take 1 argument and return the power base three value.

"power3" function example:

power3 (2) > return 9

power3 (5) > return 243

Write a nested for loop that prints the following output

1

1 3 1

1 3 9 3 1

1 3 9 27 9 3 1

1 3 9 27 81 27 9 3 1

1 3 9 27 81 243 81 27 9 3 1

1 3 9 27 81 27 9 3 1

1 3 9 27 9 3 1

1 3 9 3 1

1 3 1

1

Hint: Here is the psucode solution:

for row from 0 to 7 {

pad leading blanks in a row like this

for the row column from 1 to 7-row:

print a set of spaces

print left half a row

for column from 0 to row:

print spaces followed by raised to the power of the column

print right half a row

for column from row-1 to 0:

print spaces followed by 2 raised to the power of the column

print a new line

You need to figure out how many spaces to print before the number. The simple way to

compute powers of 2 is with the pow function; can you do this without it?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!