0% found this document useful (0 votes)
61 views7 pages

ITC11L (Computer Programming 1) : EXERCISE (Pre-Midterm) Conditional Control Structures

The document describes a pre-midterm laboratory exercise for students in an Information Technology course. The exercise involves coding programs using different conditional control structures in C++. Students are given two sample programs that contain errors and are tasked with identifying the errors, correcting the code, and verifying the outputs. The goals are for students to practice using conditional control structures and debugging code based on specifications. References on C++ programming are also provided.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views7 pages

ITC11L (Computer Programming 1) : EXERCISE (Pre-Midterm) Conditional Control Structures

The document describes a pre-midterm laboratory exercise for students in an Information Technology course. The exercise involves coding programs using different conditional control structures in C++. Students are given two sample programs that contain errors and are tasked with identifying the errors, correcting the code, and verifying the outputs. The goals are for students to practice using conditional control structures and debugging code based on specifications. References on C++ programming are also provided.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Republic of the Philippines

RIZAL TECHNOLOGICAL UNIVERSITY


Cities of Mandaluyong and Pasig

COLLEGE OF ENGINEERING, ARCHITECHTURE AND TECHNOLOGY

INFORMATION TECHNOLOGY
DEPARTMENT
.

ITC11L
(COMPUTER PROGRAMMING 1)

EXERCISE (Pre-Midterm)
CONDITIONAL CONTROL STRUCTURES
Student Name /

Members (if Group): Name Role

Section:

Professor:

/mbf INFORMATION TECHNOLOGY DEPARTMENT

Republic of the Philippines


RIZAL TECHNOLOGICAL UNIVERSITY
Cities of Mandaluyong and Pasig

COLLEGE OF ENGINEERING, ARCHITECHTURE AND TECHNOLOGY

I. PROGRAM OUTCOME/S (PO) ADDRESSED BY THE LABORATORY EXERCISE


• Analyze a complex problem and identify and define the computing requirements appropriate to its
solution. [PO: B]
• Design, implement and evaluate computer-based systems or applications to meet desired needs and
requirements. [PO: C]

II. COURSE LEARNING OUTCOME/S (CLO) ADDRESSED BY THE LABORATORY EXERCISE


• Select and apply appropriate program constructs in developing computer programs. [CLO: 2] •
Develop, test and debug computer programs based on a given specification using the fundamental
programming components. [CLO: 3]

III. INTENDED LEARNING OUTCOME/S (ILO) OF THE LABORATORY EXERCISE


At the end of this exercise, students must be able to:
• Know the importance of each type of conditional control structures and how to implement it in a
C++ program.
• Write C++ programs that use different conditional control structures to solve problems.

IV. LABORATORY EXERCISE


Directions: Encode the programs below then build and run the program. The program contains errors. Identify a
program statement/s that contains a syntax error or a logical error then write it in the Statement(s) column in the
table provided. Correct the error, rebuild, and rerun the program. In the Remark column, indicate the correction
you have made with the statement. Do this process until no errors are encountered in the program. Make sure it
satisfies the program specifications and the output of the program. Note: Indicated inside the parenthesis after the
Program No. is the name of the project.

Program No. 1 (cond1)


The program asks the user to enter his/her name, computes his/her grade and displays a remark. The name
entered by the user will be stored in variable name that can store up to 15 characters. There will be three grades
that will be entered by the user, the prelim grade, midterm grade and prefinal grade which will be stored to
variables PG, MG, and PFG variables respectively of float data type. The final grade will be computed using the
formula FG = PG * .3 + MG * .3 + PFG * .4. Final grade will be stored to variable FG of float data type. The
program should display the Final Grade(FG) in two decimal places. The program displays a remark based on the
computed final grade of the student. The remarks are shown in the sample outputs.
Final Grade(FG) Remark/Sample Output

/mbf INFORMATION TECHNOLOGY DEPARTMENT

Republic of the Philippines


RIZAL TECHNOLOGICAL UNIVERSITY
Cities of Mandaluyong and Pasig

COLLEGE OF ENGINEERING, ARCHITECHTURE AND TECHNOLOGY


75-100
0-65

Invalid input such as negative


numbers

Code:

include<iostream>

#include<iomanip.std>

using namespace std;

int main() {

int name[15];

float PG, MG, PFG;

float FG;

cout << "Enter your name: ";

cin >> name;

cout << "Enter Prelim Grade: ";

cin << PG;

cout << "Enter Midterm Grade: "; cin

<< MG;

/mbf INFORMATION TECHNOLOGY DEPARTMENT

Republic of the Philippines


RIZAL TECHNOLOGICAL UNIVERSITY
Cities of Mandaluyong and Pasig

COLLEGE OF ENGINEERING, ARCHITECHTURE AND

TECHNOLOGY cout << "Enter Prefinal Grade: ";

cin >> PFG;


FG = PG * .3 + MG * .3 + PFG * .4;

cout<<fixed<<setprecision(2);

if (FG >= 75 && FG <= 100){

cout << "Congratulations " << name << "!!!" << endl;

cout << "Your grade is " << FG << endl;

cout << "You passed.;

else if (FG >= 6 && FG < 75);

cout << "Bad news " << name << "!!!" << endl;

cout << "Your grade is " << FG << endl;

cout << "You failed";

else

cout << "Hi " << name << "!!!" << endl;

cout << "Your grade "<<FG<<" is invalid." << endl;

cout << "There is something wrong";

return 0;

Statement(s) Remark

/mbf INFORMATION TECHNOLOGY DEPARTMENT

Republic of the Philippines


RIZAL TECHNOLOGICAL UNIVERSITY
Cities of Mandaluyong and Pasig

COLLEGE OF ENGINEERING, ARCHITECHTURE AND TECHNOLOGY


Program No. 2 (cond2)
The program is temperature converter that converts temperature from Celsius to Fahrenheit and vice versa. The
program uses the variables Fah, Cel to store the temperature values in float data type. The variable ltr keeps the
option selected by the user in char data type. The program should display the converted temperature in two
decimal places. The program displays a remark based on the option selected by the user. The remarks are
shown in the sample outputs.
ltr value Remark/Sample Output

a or A

b or B

x or X

Code:

/mbf INFORMATION TECHNOLOGY DEPARTMENT

Republic of the Philippines


RIZAL TECHNOLOGICAL UNIVERSITY
Cities of Mandaluyong and Pasig

COLLEGE OF ENGINEERING, ARCHITECHTURE AND

TECHNOLOGY #include<iostream>
#include<iomanip>
using namespace std;

int main() {

float Fah, Cel

int ltr;

cout << "TEMPERATURE CONVERTER\n";

cout << "A - Centigrade to Fahrenheit\n";

cout << "B - Fahrenheit to Centigrade\n";

cout << "X - Exit\n";

cout << "Enter your choice:";

cin >> ltr;

switch (ltr) {

case 'a': case A: {

cout << "Enter Celsius temperature:";

cin >> Cel;

Fah = 9 * Cel / 5 + 32;

cout << fixed << setprecision(2);

cout << Cel << " degrees is " << Fah << " in Fahrenheit.";

break;

case 'b': case 'B': {

cout << "Enter Fahrenheit temperature:";

cin << Fah;

Cel = 5 * (Fah - 32) / 9;

cout << fixed << setprecision(4);

cout << Fah << " degrees is " << Cel << " in Celsius";

break;

case 'x': case 'X': exit(0);

default: cout << "Wrong entry.Not in the choices.";

return 0;

/mbf INFORMATION TECHNOLOGY DEPARTMENT

Republic of the Philippines


RIZAL TECHNOLOGICAL UNIVERSITY
Cities of Mandaluyong and Pasig

COLLEGE OF ENGINEERING, ARCHITECHTURE AND TECHNOLOGY


Statement(s) Remark

V. REFERENCES
• Abraham (2015). Coding for dummies. John Wiley and Sons: Hoboken, NJ
• Zak, D (2015). An Introduction to Programming with C++. 8th Edition
• Cadenhead, R et. Al. (2016). C++ in 24 Hours, Sams Teach Yourself (6th Edition).Sams Publishing •
McGrath, M. (2017). C++ programming in easy steps (5th ed.). Warwickshire, United Kingdom: Easy
Steps Limited
• Tale, T. (2016). C++: The Ultimate Beginners Guide to C++ Programing. CreateSpace Independent
Publishing Platform
• http://cs.uno.edu/~jaime/Courses/2025/devCpp2025Instructions.html

Submission: October 11, 2021 (Do take note that this will be part of your Midterm exam).

/mbf INFORMATION TECHNOLOGY DEPARTMENT

You might also like