Hi,
I'm new to C and need to make a program that displays the output of the first six powers of 2 like this: 1 2 4 8 16 32
(2 to the power of 0, 2 to the power of 1, 2 to the power of 2, and so forth)
I made the program so far without using arrays and was wondering if i could get some help on how to use them in this program. Here is what I've done so far:
#include <stdio.h>
#include "math.h"
main()
{
double x=2, y=0;
double d;
for(y=0;y<6;y++ )
{
d=pow(x, y);
printf("%g\t", d);
}
getchar();
}
I'm new to C and need to make a program that displays the output of the first six powers of 2 like this: 1 2 4 8 16 32
(2 to the power of 0, 2 to the power of 1, 2 to the power of 2, and so forth)
I made the program so far without using arrays and was wondering if i could get some help on how to use them in this program. Here is what I've done so far:
#include <stdio.h>
#include "math.h"
main()
{
double x=2, y=0;
double d;
for(y=0;y<6;y++ )
{
d=pow(x, y);
printf("%g\t", d);
}
getchar();
}
Comment