1. ## power calculate

Write a function that calculates a to the power b. Write another function that calls this function and print a table of exponantials for the given a, b values. Exponents are from 0 to a, and numbers are from 0 to b. The output is:

http://img442.imageshack.us/img442/667/image267ym0.jpg

it's one of my homework questions. i did all of them expect that one. can anyone help me please?

2. Have you written a function that calculates the power?
Have you written a function that calls that function?
Do you know how to output text to the screen?

3. Do the first part first.

You'll need to use loops to do both parts of the problem.

Do you know how to compute a to the power of b on paper? If you do, then post it.

http://www.cprogramming.com/tutorial/c/lesson3.html

4. Originally Posted by Elysia
Have you written a function that calculates the power?
Have you written a function that calls that function?
Do you know how to output text to the screen?
on the table, left side is power (a), upside is number (b).

power function :

Code:
```#include <stdio.h>
#include <math.h>

int main() {

int a,b,c;
printf("first number: ");
scanf("%d",&a);
printf("second number: ");
scanf("%d",&b);
c=pow(a,b);
printf("result: %d",c);
getchar(); getchar();

}```

5. You were supposed to write the power function, were you not? Not use an existing.

6. Shouldn't I use that pow function ? pow(a,b) ? Do I've to write a new function ?

Code:
```#include <stdio.h>

int main() {

int a, b, result;
int c;

printf("number ");
scanf("%d", &a);

printf("power ");
scanf("%d", &b);

result = 1;

for (c=0; c<b; c++) {
result *= a;
}

printf("result %d\n", result);

getchar(); getchar();
return(0);
}```

7. Write a function that calculates a to the power b.

8. Actually, it wouldn't be a bad idea to use the pow function as a placeholder until you write the rest of the program. Then you can make sure that your program works, and write the function that you will use afterwards.

9. Originally Posted by MacGyver
in the assignment paper here it's the table :

http://img530.imageshack.us/img530/7503/gdsf1lx8.jpg

i think, a is exponent. b is number that we'll calculate the result. ? am i wrong ? then, i did a new table in my first post. i'm working on that table for the code.

10. Wouldn't b be the exponent here?

11. But it says

Exponents are from 0 to a, and numbers are from 0 to b
We stopped solving the question, started to discuss about the question

Then, if it's b is the exponent. Then, let's solve it with a is number, b is exponent.

if a is 2, b is 3. The result ? 8 or 9. ?

12. In exponental notation, the big number is called the base and the small number is called the exponent. so:
Code:
```     exponent
base```
a is the base and b is the exponent.
Code:
``` b
a```
if a is 2, b is 3. The result ? 8 or 9. ?
Code:
``` 3
2 = 2 * 2 * 2 = ?```