Cs October 14 2010

# Cs October 14 2010 - Cs cs exam Friday oct 22 2:30-4:30 pm...

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

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

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

Unformatted text preview: Cs October 14 2010 cs exam: Friday oct 22 2:30-4:30 pm EIT 1015/MC4020 Midterm: -basic c programming, part 1 in textbook w/ class stuff +math.h, Horner’s method, bisection algorithm, Euclid, etc. Structures (unlikely to be on midterm, ch. 16)-group several named member variables <-“members” eg. structure for time of day (24h time) Struct tod{ Int hours; declaration of structure with tog “tod” int minutes; }; int main(void){ struct tod now={16,50}; -initializer 16:50 now[16][50] 16=hours, 50 = minutes struct tod later; later.hours=18; later.minutes=0; -later [18][0] printf(“%d:%n”,now.hours,now.minutes); => 16:50 printf(“%d:%n”,later.hours,later.minutes); => 18:0 return0; } void todPrint(struct tod when){ printf(“%d:%02d”,when.hours,when.minutes); } int main(void) { struct tod later={18,0}; todPrint(later); return 0; } 18:00 Returning structures struct tod todAddtime(struct tod when, int hours, int minutes){ when.minutes+=minutes; when.hours+=(when.minutes)/60+hours; when.minutes %=60; when.hours%=24; return when; }...
View Full Document

## This note was uploaded on 12/10/2011 for the course CS 137 taught by Professor Clarke during the Fall '10 term at Waterloo.

### Page1 / 3

Cs October 14 2010 - Cs cs exam Friday oct 22 2:30-4:30 pm...

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

View Full Document
Ask a homework question - tutors are online