Fundamentals of Programming Lab Journal - Lab # 13: Objective
Fundamentals of Programming Lab Journal - Lab # 13: Objective
Fundamentals of Programming
Enrollment #: _________________________________
Class: _________________________________
Objective
This lab will cover structures in C++, pointers to structures and arrays of structures. Student will
also do an exercise on passing structures to functions.
Tasks :
3. Declare a variable of type Point, a pointer to Point and an array of 10 Points. Assign the
address of the variable to the pointer.
Point p;
Point *pj;
Point px[10];
Pj=&p;
4. Using pointer variable set the value of x-coordinate in structure Point to 5 and that of
y-coordinate to 10.
5. Declare a structure Date. Declare another structure Project with fields: ID, startDate
and endDate. (Use nested structures).
6. How would you call the function void displayDate(Date) where Date is a structure.
Exercise 1
Write a program with a structure Rectangle having fields length and width. Get
user input for the fields and pass it to a function display(Rectangle) to output the
length and width of the rectangle.
Now change this program to add the function getInput(Rectangle &) and get the
user input within the function. Change the function display(Rectangle) to
display(Rectangle *) and use the pointer variable to display the length and width
of the rectangle.
Exercise 2
+++++++++++++++++++++++++