I have a question,maybe it's stupid.I wrote that code to calculate expontiation :
#include<stdio.h>
int i=0;
float power(int a,int b);
main()
{ int base,exp;
printf("Base:\n");
scanf("%d",&base);
printf("Exp:\n");
scanf("%d",&exp);
power(base,exp);
system("pause");
}
float power(int a,int b)
{ float result=1;
for (i=0;i<b;i++)
{
result=result*a;
}
printf("result = %lf \n",result);
}
What got me confused was that i gave as input base=2 and exp=100 and the output was correct.The thing i don't understand is how does the program calculates the correct number even though float type is 4byte=32 bits,which means that the greatest number a float(result) variable can get is 2^32-1<<2^100