DOC PREVIEW
Radford ITEC 310 - Lecture Notes

This preview shows page 1-2 out of 7 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Chapter 9 Enumeration TypesObjectivesEnumeration TypeEnumeration Type (Cont.)Slide 5Slide 6ReferencesChapter 9 Enumeration TypesBy C. ShingITEC DeptRadford UniversitySlide 2ObjectivesUnderstand how to use enumerate data typeSlide 3Enumeration TypeList all member in a setHelp internal documentationDeclare data type enum enumerate_nameForm: enum enumerate_name {member1[=n1], …, memberN}Default n1=0, and increment by 1 for the next memberSlide 4Enumeration Type (Cont.)Example:enum computer { supers, mains, minis, micro, pda};typedef enum computer computer;computer c, d;c=mains;d= find_next_member (c);printcomputer(d);computer find_next_member (computer c) {return (computer) (((int) c +1)%5);}Slide 5Enumeration Type (Cont.)Example:void printcomputer (computer c) {switch (c) { case supers: printf(“Supercomputer\n”; break; case mains: printf(“Main Frame\n”; break; case minis: printf(“Minicomputer\n”; break; case micro: printf(“Microcomputer\n”; break; case pda: printf(“Personal Digital Assistant\n”; break; default: printf(“Error!\n”); exit(1);}Slide 6Enumeration Type (Cont.)Example: (Alternative)computer find_next_member (computer c) { switch (c) { case supers: return mains; break; case mains: return minis; break; case minis: return micro; break; case micro: return pda; break; case pda: return supers; break; default: printf(“Error!\n”); exit(1);}Slide 7ReferencesDeitel & Deitel: C How to Program, 4th ed., Chapter 10, Prentice


View Full Document

Radford ITEC 310 - Lecture Notes

Documents in this Course
Load more
Download Lecture Notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture Notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?