COSC 175 Lecture Notes - Lecture 15: Array Data Structure

101 views8 pages

Document Summary

Problem: input 5 scores, compute total, average, i(cid:374)put (cid:1005)(cid:1004)(cid:1004) . Group of variables referred to by one name, composed of elements. Or member each item in the array: referred to by one name with an index a[0], a[1] Type: type of each member in array, can be of any type. Size: number of members in the array(constant, size must be known, cannot be x. Dimension each array before it is used one time only. Float testscores[30]: or declare size as a constant. Store float testscores[6]; indicates which item in the array referring to. Reference array element using subscript or index. Last element subscript is one less than size: int buf[100], buf[0]; - first element of buf, buf[99]; - last element of buf. No (cid:272)he(cid:272)ki(cid:374)g for (cid:862)out of (cid:271)ou(cid:374)ds(cid:863: buffer overflow big vulnerability. Can use variables, expression, or constant as subscript: angle[0] 0 4. 93, angle[1] = -15. 2, val[i + 2] = val[i] + [val i + 1];

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents