Notice: Due 5pm, Wednesday, 3 October 2001.
Each lab is due with the lab instructor
no later than 5 pm on the Wed after the lab.
four06% 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"); } four06% lab5 Enter N:10 1 4 9 16 25 36 49 64 81 100 four06% lab5 Enter N:5 1 4 9 16 25 four06%lab5 Enter N:0 four06% lab5 Enter N:-1 N out of range four06% lab5 Enter N:11 N out of range