summaryrefslogtreecommitdiff
path: root/wk2/sect2/array.c
blob: 093a7a13972275af87235ab06b6e28c94f3dac96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <cs50.h>
#include <stdio.h>

int main(void)
{
    int n;
    do
    {
        n = get_int("Length: ");
    }
    while (n < 1);
    int array[n];
    array[0] = 1;
    int i = 1;
    do
    {
        array[i] = array[i - 1] * 2;
        i++;
    }
    while (i < n);
    for (int j = 0; j < n; j++)
    {
        printf("%i\n", array[j]);
    }
}