COMP 002 - Midterm Lecture Assignment 4 (Week 4 to 6 - C++ Basic Structures)
COMP 002 - Midterm Lecture Assignment 4 (Week 4 to 6 - C++ Basic Structures)
Name: Score:
Name: Program:
Name: Course Code - Section:
Name of Faculty: Asst. Prof. Ma. Ymelda C. Batalla
Learning Outcomes:
Upon completion of this activity, the students should be able to:
▪ Recognize the significance of relevant and descriptive variable names in programming;
▪ Create concise variable names that reflect its purpose in every programming problem; and
▪ Evaluate expressions correctly by following the order of the operations based on their precedence.
Instructions:
▪ This activity is composed of two (2) to three (3) students per group.
▪ Create an appropriate variables name for the following problems (1pt each).
1. Calculate the area of a rectangle.
a.
b.
c.
2. Convert the temperature from Fahrenheit to Celsius.
a.
b.
3. Find the largest of three given numbers.
a.
b.
c.
d.
4. Determine a student's grade based on their average of three quiz scores.
a.
b.
c.
d.
5. Calculate the factorial of a given non-negative integer.
a.
b.
c.
6. Calculate the simple interest using principal, rate of interest, and years.
a.
b.
c.
d.
▪ Evaluate the following expressions using the operator’s precedence (5pts each).
1. 20 - 13 % 2 + 17 / 4
Solution:
2. 7.0 / 2 + 3 * 4 - 10 % 5
Solution:
3. a = 5, b = 3, c = 7
++a * --b + --c /--b
Solution:
4. a = 5, b = 3, c = 7
!(--c % --a != a++ - --b )
Solution:
▪ Identify which of the following is a valid identifier; write VALID if the identifier is acceptable; however, write
INVALID and reasons why the identifier is not acceptable (1 pt each).
1. firstC++Prog
2. 3FeetYard
3. CPP_Assignment
4. Monthly Pay
5. firstNumber#
6. travel_time
7. _number
8. InchesInCentimeter
9. bonusAmount$
10. Jack’sQuizScore
▪ Save the group output as pdf file format and each member must upload the assignment using the filename
format: Last Name_ Last Name_ Last Name - COMP 002 - Midterm Lecture Assignment 4
▪ Submission due date: November 7, 2024, 11:59 PM