1 / 20

Documenting a Structure in C

Documenting a Structure in C. Explaining a Structure Build. Problem solving:. What defines a Student? In what ways can a students information be collected?. This student name can be Tim who is 21 years old and has an ID of 5869403. The Students name is Tim His age is 21 5869403 is his ID.

ernie
Download Presentation

Documenting a Structure in C

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Documenting a Structure in C Explaining a Structure Build

  2. Problem solving: • What defines a Student? • In what ways can a students information be collected?

  3. This student name can be Tim who is 21 years old and has an ID of 5869403. • The Students name is Tim • His age is 21 • 5869403 is his ID

  4. What does the program do?: The program creates a structure array model to gather information from a student. The information is gathered and printed.

  5. Create Structure Define Structure Variables Define Values in the structure Print out the Values contained in the Structure

  6. Sequence: main() ●Declare: Structure for Student ●Initialize: Variables Student Tim contents ●Print out the Students information

  7. Creating a Structure Donation Donator

  8. Declaration of Structure Initialize Variables and Arrays Within Structure Instance 1 Instance 2 Call Structure Within Main Function Pointer to Structure Within Main Function Print Dialogue and Scan for Input (Name) Print Dialogue and Scan for Input (Value) Print Recorded Character Strings and Final Dialogue

  9. Declaration: struct donor Initialize: • Float for donation amount • Character Array for First Name • Character Array for Last Name

  10. Sequence: main() • Call Structure • Print Dialogue Asking for Donor’s First and Last Names • Scan Input Information and Store Within Character Arrays in Structure • Print Dialogue Asking for Donation from Donor • Scan Input Value and Store Within the Float in Structure

  11. Sequence: main() [cont.] • Print Final Dialogue, Denoting Donor’s First and Last Names • Retrieved from Character Strings from Structure • Print Donation Amount Pertaining to Donor • Retrieved from Float • Specify Decimal Places

  12. The main difference between the two blocks of code is the utilization of a pointer. The new line of code can only be read in C++, due to it using the new operator. The new operator returns a non-zero pointer to the object. Also, the pointer version of the code utilizes the -> pointer operator rather than the . operator. Either of these operators would successfully retrieve a pointer. Otherwise, the two blocks of code function identically and display the same command dialogue when prompted.

More Related