Midterm Exam # 1 F96 KEY



MIS 304 Midterm Exam 10/11/96

Short Answer (10 points each):

1.) Please explain explicitly the difference between declaring a structure and defining a variable. Make sure you explain clearly what each does and why they are different. You may use the following examples in your explanation.

struct HelpMePlease {

char szWhyAmIHere[100];

float fVeryLowGPA;

int iHopeforaCurve;

};

int i;

A definition reserves memory a declaration does not. The declaration of HelpMePlease specifies a name and attributes but allocates no memory. The defintion of i (in int i) allocates 2 bytes of memory and identifies it with the symbol i.

2.) Using the above structure do only the following (DO NOT WRITE AN ENTIRE PROGRAM):

a. Define a single variable to store a char array, a float, and an int.

b. Initialize the variable with the following values: “In order to learn C++”, 1.25, 0

c. Display the stored values to the monitor.

a & b: HelpMePlease stOne = {“To learn programming”, 1.5, 0}; // You could also initialize them individually after defining the variable. For example stOne.fVeryLowGPA = 1.5;

c: cout ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download