{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Csc 1500 lecture 11 8 a more comprehensive example

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: a de ned component of the struct. CSC 1500 { Lecture 11 8 A More Comprehensive Example #include <stdio.h> struct date { int day int month int year } int main(void) { struct date int today, dob age printf("Date of birth (dd mm yy)? ") scanf("%d %d %d", &dob.day, &dob.month, &dob.year) printf("Today (dd mm yy)? ") scanf("%d %d %d", &today.day, &today.month, &today.year) if (today.month > dob.month || (today.month == dob.month && today.day >= dob.day)) age = today.year - dob.year else age = today.year - dob.year - 1 printf("Age = %d\n", age) return 0 } Date of birth (dd mm yy)? 27 04 87 Today (dd mm yy)? 21 11 97 Age = 10 CSC 1500 { Lecture 11 9 Initializing Structures struct variables can be initialized as follows: day month year struct date { in...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online