You are on page 1of 4

CS10-8L: Computer Programming Laboratory

Machine Problem #9: Conditional Statements

Name: Score:

Section: Date:

OBJECTIVES
● To familiarize the students with the MATLAB interface.
● To enable the students to use some basic operations.

Instructions:
1. Save your file as Surname_Firstname_MP9. Ex. Santos_Jared_MP6

2. You will submit a zip file containing the following and send it to BB.

a. PDF file of Machine Problem 8 provided with the screenshot of your answers.
b. MATLAB function script with .m extension.

3. Your program must have comments for each section.


Header Comments:
%{
This demo program shows how good a MATLAB program is
Written by: Raymond Sedilla
Date: August 27,2020
Time: 2:20pm
Program: BSIE
Course: CS10-8L
Section: B20
School: Mapua University
%}

MACHINE PROBLEM

1. Consider an arithmetic expression of the form a # b = c. Check whether it is possible to replace with one of the
four signs: +, -, * or / to obtain a correct expression.

1st Sample Program Run

Enter value of a: 2
Enter value of b: 3
Enter value of c: 5

Output: True

Note: Output is true because 2 and 3 can result to 5 using +.

Prepared by: Raymond Sedilla, Mapua University


CS10-8L: Computer Programming Laboratory
Machine Problem #9: Conditional Statements

2nd Sample Program Run

Enter value of a: 8
Enter value of b: 3
Enter value of c: 2

Output: False

Note: Output is false because 8 and 3 will not result to 2 using +, -, *, and /.

Test
a b c Expected Output
Sample
1 2 3 5 True
2 8 2 4 True
3 8 3 2 False
4 6 3 3 True
5 5 2 0 False
6 10 2 2 False

Prepared by: Raymond Sedilla, Mapua University


CS10-8L: Computer Programming Laboratory
Machine Problem #9: Conditional Statements

In the editor window, take a screenshot and paste your output:

Prepared by: Raymond Sedilla, Mapua University


CS10-8L: Computer Programming Laboratory
Machine Problem #9: Conditional Statements

In the command window, take a screenshot and paste your output:

Prepared by: Raymond Sedilla, Mapua University

You might also like