
You can assume that the array is full (each element of the array points to an Item object). Write a function that prints the descriptions of all the elements in array itemPtrs where the price is 2.0 or over. Write client code to dynamically allocate an Item object, store it's address in the first position of array itemPtrs, and set it's item number to 10, it's description to "Granny Smith Apples", and it's price to 1.89. Write client code to declare an array called itemPtrs of 150 pointers to Item objects. struct DateĬout month day year % 100 set( 10, "Granny Smith Apples", 1.89 ) ġ3. Then write code to dynamically allocate a date, store some information in it, and print it out. Write a declaration for a structure to hold a date as 3 integer values: the month, day, and year. Strcpy( itemPtrs->desc, "Granny Smith Apples" ) ĩ. Then write code to dynamically allocate an Item struct, store it's address in the first element of itemPtrs, then set it's item number to 10, it's description to "Granny Smith Apples", and it's price to 1.89. Write a declaration for an array of 150 pointers to structs of type Item called itemPtrs. void store( Item *itemPtr, int anItem, char aDesc, float aPrice )Ĩ. Your function should assign the item number, description, and price to the struct data members.

Write a function that takes as parameters a pointer to an Item struct, an item number, a description, and a price. Strcpy( itemPtr->desc, "Granny Smith Apples" ) ħ. Then write code to change the value of num to 5 and print it's value without using the variable name (use the pointer). For example, given integer variable num, write code to declare a pointer variable called numPtr and store the address of num in numPtr. This is not particularly useful, it just demonstrates that you know how pointers work. I expect you to be able to manipulate the value of a variable of a simple type using a pointer.

Note: All chapter numbers refer to the Gaddis textbook.ġ. Please let me know if you find any errors in the answers. ITSE 1307 - Introduction to C++ Programming
