lecture26-apr1 - Announcements Lecture 26 Exam 2 on Friday...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Announcements Lecture 26 • Exam 2 on Friday • Assignment 5 – Q&A; extended the due date to Sunday night • Topics for today Finish advanced declarations (Ch. 18) Exam review Initializers • A declarator that represents a variable may be followed by an initializer: int i = 0, *p = &i, a[5] = {1,2,3,4,5}; • An initializer for an array, structure, or union must contain only constant expressions, never variables or function calls: #define N 2 int powers[5] = {1, N, N*N, N*N*N, N*N*N*N}; • An initializer for a variable with static storage duration is also limited to constant expressions: #define FIRST 1 #define LAST 100 static int i = LAST - FIRST + 1; Initializers (2) • If a variable has automatic storage duration (and is not an array, structure, or union), its initializer can be any expression of the appropriate type—the expression need not be constant: int f(int n) { int last = n - 1; } • What is the initial value of a variable if we don’t explicitly initialize it? – Variables (numeric) whose storage duration is
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

lecture26-apr1 - Announcements Lecture 26 Exam 2 on Friday...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online