Exercise 9.1 Given the following structure members, write a simple program to print out the member of the structure. struct electricity { char city[20]; int year; double usage; };
struct Resource { char material[30] double longitude; double latitude; double quantity; char units[20] }; Declare and Initialize the structure and printout your own specification for the output.
Exercise 9.2 Write a program to read a file as follows using an array of structures. Display this file neatly on the screen. Name Height(ft) Age SSN Jean Garcia 5.61 21 123-45-6789 Tony Lutz 6.12 36 987-65-4321 Roger Ron 5.87 87 111-22-3333 Jim McKay 3.14 4 444-55-6666
Calculate for the average height in feet and display to the screen.
Exercise 9.3 The following data is some information about Mr Ahmad credit card. The data is store in a file, name mycard.txt. VISA cimb 2011 VISA maybank 2010 Masters rakyat 2015 Amex islam 2010 Dinners public 2009
Help Mr Ahmad to develop a program that can store and retrieve the information about his credit card. Declare a structure to store the information with structure name cardinfo. The data member of the structure is cardname, bankname and expiry. Initialize card1 to take the data members of the structure cardinfo. Open and read the input in the data file. Check either the input file is in the same directory as the code or not. Initialize the input to card1 Print out the info to the screen