Arrays, Strings, Scope, and Other Magic Stuff
A Freshman Engineering Computer Programming Lab
Developed by Dr. P.K. Imbrie, Purdue University
Individual Check for Understanding
This is a written check for understanding. Put your name as
well as the names of the team members present, your team
number, your team role and lab time on your paper.
What is the output of the following program?
#include <stdio.h>
#define N 5
int main()
{
int a[N];
int I, sum = 0;
for (I = 0; I < N; ++I)
a[I] =
7 + I * I;
for (I = 0; I < N; ++I)
printf("a[%d]
= %d \n ", I, a[I]);
for (I = 0; I < N; ++I)
sum += a[I];
printf("\nsum = %d\n", sum);
return 0;
}
Lesson
| Instruction
to Students |
Individual Check for Understanding
©2001,
P.K.
Imbrie
These materials may be duplicated for educational purposes
if properly credited.
|