hello guys im sorry for asking so much some codes in K&R are complicated
Code:
#include <stdio.h>
/* test power function */
int power(int m, int n);
/* power: raise base to n-th power; n >= 0 */
int power(int base, int n)
{
int i, p;
p = 1;
for (i = 1; i <= n; ++i)/*here i=0 i<=n i++
*like lets say we do 1 for int n it will run from 1 till num*/
p *= base;//p=p * base;
return p;
}
int main(void)
{
int i;
for (i = 0; i < 10; ++i)
printf("%d %d %d\n", i, power(2,i), power(-3,i));
getchar();
return 0;
}
here we passed i then power(2,i) and power(-3,i));
in our orginal function power he set p=1 so if we passed base that means p=1 *2
shouldnt this alawys 1*num=num ? or what coz it gets diff results like first
set is 1 ,1 shoudlnt it be 2,-3 ??