We got the compiler to work, but are now stuck with the powers program. We need a program that calculates a^b when a and b are given (and they can be both positive and negative). The code we have so far:
Code:
#include <stdio.h>
int i,m;
int k=1
int j=0;
int main()
{
printf("base....:D");
scanf("%d",&k);
printf("\n exponent......:D");
scanf("%d",&i);
for(j=0,j<i,j++)
{
m*=k;
}
printf("%d to the power of %d is %d ",m,i,k);
return 0;
}
Does anyone know why it isn't working? Also, how can we make it work for negative numbers as well as positive?