Question: 3. Structures In order to explain how a structure works, let's look at an example. A loan usually has several components in it. For simplicity,
3. Structures In order to explain how a structure works, let's look at an example. A loan usually has several components in it. For simplicity, we assume for now that no name or personal identification number is involved. Instead, we use the loan number to identify a loan. The components of a loan in our example are: a loan ID, assuming an integer, .the loan amount, which for now we assume is a float, .the interest rate, another float, and the term of the loan, which represents the integer of months until the loan is paid in full. One thing everyone is concerned about in a loan is the monthly payment. A program that computes the monthly payment for a loan would be very useful. One way to compute the monthly payment is: (rate + 1)term (rate + 1)term1 payment amount* rate Note that your bank may use a different formula to compute loan payment, but this is a good example. As you may have noticed in the description of the loan components, it seems that we could have a new variable type, let's say Loan, which includes all of the four components in it. Thus, we wish to define a new type of variable that can keep four variables of various types within one. A struct allows to do this verv easi
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
