Recitation 5 must be submitted
following directions at: submissions on or before
|
Outline: Write a MIPS program that uses two integer arrays (A and B) of size 10. The program should do that following:
Recitation Program (C) | C Run and Output |
---|---|
% cat rec5.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"); } | % rec5 Enter N:10 1 4 9 16 25 36 49 64 81 100 % rec5 Enter N:5 1 4 9 16 25 %lab5 Enter N:0 % rec5 Enter N:-1 N out of range % rec5 Enter N:11 N out of range |
Contents of submission
for Recitation 4: Last Name, First Name; Course Number; Recitation Number (4).
|