You can model your program after the following c program:
pandora% cat lab5.c
#include <stdio.h>
#include <stdlib.h>
void main(void)
{
int A[10] = {1, 3, 5, 7, 9, 11, 13, 15, 17, 19};
int B[10];
int N;
int OldB;
int i;
printf("Enter N:");
scanf("%i", &N);
if (N < 0 || N > 10) {
printf("N out of range\n");
exit(1);
}
i = 0;
OldB = 0;
while (i < N) {
B[i] = OldB + A[i];
OldB = B[i];
i = i + 1;
}
i = 0;
while (i < N) {
printf("%i", B[i]);
printf(" ");
i = i + 1;
}
printf("\n");
}
pandora% lab5
Enter N:10
1 4 9 16 25 36 49 64 81 100
pandora% lab5
Enter N:5
1 4 9 16 25
pandora%lab5
Enter N:0
pandora% lab5
Enter N:-1
N out of range
pandora% lab5
Enter N:11
N out of range