define winter 1
play

#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;


  1. #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;

  2. • – – –

  3. typedef struct { char name[40]; int year; double gpa; } Student; M e g a n … 2014 3.78

  4. typedef struct { char name[40]; int year; Student student; double gpa; } Student; strcpy(student.name, "Megan"); student.year = 2014; student.gpa = 3.78;

  5. typedef struct { char name[40]; int year; Student makeStudent ( char name[], int year, double gpa; double gpa) { } Student; Student student; strcpy(student.name, name); student.year = year; student.gpa = gpa; return student; }

  6. typedef struct { char name[40]; int year; Student student1, student2; double gpa; … } Student; student1 = makeStudent("Bob", 2012, 2.52); student2 = makeStudent("Crystal", 2013, 3.1);

  7. typedef struct { char name[40]; int year; double gpa; } Student; Student student = {"Bob", 2012, 2.52}; // Doesn't work: // Student student; // … // student = {"Bob", 2012, 2.52};

  8. typedef struct { char name[40]; int year; void printStudent (Student s) { double gpa; printf("%s:\n Class of %d\n GPA: %4.2lf\n", } Student; s.name, s.year, s.gpa); }

  9. • • • –

Recommend


More recommend