hi im trying to write a C program that produces an array like this
1,2,4,8,16...
Basically i produce an array with with the power of 2 starting at 0 and going up to n. Here is my current code: However the array dosent show. What is the problem?
# include <stdio.h>
# include "simpio.h"
# include "genlib.h"
# include "strlib.h"
# define maxElements 500
main()
{
int a,b,c,d,e,f,g;
int nArray[maxElements];
printf("what is the max amount of 2's you want?");
a=GetInteger();
b=0;
c=a;
d=2;
while(c!=0)
{
e=a;
while(e!=0)
{
d=d*2;
e=e-1;
printf("yo");
}
if(e==0)
{
d=1;
a=a-1;
nArray=d;
b=b+1;
c=c-1;
break;
}
else
a=a-1;
nArray=d;
b=b+1;
c=c-1;
}
getchar();
}