-
Notifications
You must be signed in to change notification settings - Fork 0
/
pow.c
42 lines (39 loc) · 812 Bytes
/
pow.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <stdio.h>
int main (void)
{
float i, j, k, l;
printf ("please enter the base number: \n");
scanf ("%f", &i);
printf ("please enter the exponent number: \n");
scanf ("%f", &j);
l = i;
if (j > 0)
{
if (j - (int)j == 0)
{
k = (int)j;
for ((int)k; (int)k > 1; (int)k --)
l *= i;
}else
{
printf("wait, I' m learing\n");
}
}else if (j < 0)
{
if (j - (int)j == 0)
{
k = - (int)j;
for ((int)k; (int)k > 1; (int)k --)
l *= i;
l = 1 / l;
}else
{
printf("wait, I' m learing\n");
}
}else
{
l = 1;
}
printf ("%.2f ^ %.2f = %f", i, j, l);
return 0;
}