I'm enjoying learning C, but sometimes BASIC is so much simpler. It struck me again when I was completing an exercise to display the powers of 2.
Here is the C version...
#include <stdio.h>
#include <math.h>
int main()
{
int b=0;
float value=2.0;
int increment=0;
float result;
for(b=0;b<=10;b++)
{
result=pow(value,increment);
printf("%.1f to the power of %d is %.1f\n",value,increment,result);
increment+=1.0;
}
return 0;
}
Here is the alternative in BASIC using SpecBAS...
10 FOR I=0 TO 10
20 LET A=2
30 PRINT A;" TO THE POWER OF ";I;" IS ";POWER(A,I)
40 NEXT I
50 STOP