SLIDE 1
#define WINTER 1 #define SPRING 2 typedef int coinValue; - - PowerPoint PPT Presentation
#define WINTER 1 #define SPRING 2 typedef int coinValue; - - PowerPoint PPT Presentation
#define NUM_TERMS 3 #define FALL 0 #define WINTER 1 #define SPRING 2 typedef int coinValue; coinValue quarter = 25; coinValue dime = 10; #define TRUE 1 #define FALSE 0 typedef int boolean;
SLIDE 2
SLIDE 3
- –
– –
SLIDE 4
SLIDE 5
SLIDE 6
SLIDE 7
M e g a n … 2014 3.78
typedef struct { char name[40]; int year; double gpa; } Student;
SLIDE 8
Student student; strcpy(student.name, "Megan"); student.year = 2014; student.gpa = 3.78;
typedef struct { char name[40]; int year; double gpa; } Student;
SLIDE 9
Student makeStudent(char name[], int year, double gpa) { Student student; strcpy(student.name, name); student.year = year; student.gpa = gpa; return student; }
typedef struct { char name[40]; int year; double gpa; } Student;
SLIDE 10
Student student1, student2; … student1 = makeStudent("Bob", 2012, 2.52); student2 = makeStudent("Crystal", 2013, 3.1);
typedef struct { char name[40]; int year; double gpa; } Student;
SLIDE 11
Student student = {"Bob", 2012, 2.52};
typedef struct { char name[40]; int year; double gpa; } Student;
// Doesn't work: // Student student; // … // student = {"Bob", 2012, 2.52};
SLIDE 12
void printStudent(Student s) { printf("%s:\n Class of %d\n GPA: %4.2lf\n", s.name, s.year, s.gpa); }
typedef struct { char name[40]; int year; double gpa; } Student;
SLIDE 13
- –
SLIDE 14