$25
Objectives:
• Learn to use the Visual Studio 2015 platform.
• Use output formatting and pass by reference in C++.
Exercise 1:
a) In Visual C++, create a new Win32 Console Application project. Save the project in your Desktop. Name the project as Lab-03-ex1.
b) Type the following program which converts a given length to feet and inches.
Figure 1
c) To debug the program do the following ;
a. Right click on the line shown and add a “Breakpoint”
Figure 2
Figure 3
b. To run the program click “Start Debugging” or press F5.
c. The program will stop running at the line which you have put a “Breakpoint”
d. Check the “Autos” window on the bottom of the editor to see the initial values of the three variables length, feet and inches.
e. Now, to run the program press “F11” or “Step Into” in the “Debug” menu. The program will be executed line by line.
f. View how the values of the values in the variables “feet” and “Length” get modified through the reference parameters “t_feet” and “t_inches” in the “convertToFeetAndInches()” function. ( See figure 4 to 8 Below )
Figure 4
Figure 5
Figure 6
Figure 7
Figure 8
Exercise 2
Write a program to input the marks a student for two assignments and find the final mark of each assignment according to the percentages given. In your program;
1) Implement a function to find the contribution of each assignment mark sent to the function as parameters. In the function you should update two variables called CA1 and CA2, which are defined in the main program. The function heading is given below;
void findMarks (int t_marks1, int t_marks2, float &t_CA1, float &t_CA2);
The final CA mark for each assignment is calculated as shown below;
Assignment 1 20%
Assignment 2 30%
2) In the main program, input marks for 5 students and show the percentages of the marks using findMarks() function in a table as shown below. Format the output to 2 decimal places.
Student Marks1 Marks2 CA_1 CA_2
1 60 65 12.00 19.50
2 37 43 7.40 12.90
3 75 80 15.00 24.00
4 92 75 18.40 22.50
5 53 45 10.60 15.90