Erik Fredericks, frederer@gvsu.edu Fall 2025
Based on material provided by Erin Carrier, Austin Ferguson, and Katherine Bowers
All elements in a C array have the same type
For now, we are talking about static arrays
Declaring:
int arr[10];
int arr[3] = {2, 4, 6};
char arr[5];
char arr[] = "hello world";
We still access elements like in every other language (zero-indexed)
int x = arr[1];
arr[2] = 0;
unsigned int i; for (i = 0; i < 10; i++) { ... }
Newer versions of C allow you to create an iterative variable inside the loop line
while (condition) { ... }
int i = 10; while (i >= 0) { ... i--; }
do { ... } while (condition);
Same as while, but the block executes at least once!
hover over hello world in vis studio why is it 12? last char is \0 (null terminated) set arr[3] = '\0' and print..