Lab Report #1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

ADDIS ABABA INSTITUTE OF TECHNOLOGY

(AAIT)
CENTER OF BIOMEDICAL ENGINEERING (CBME)
Computational Methods Programming Lab Report #1

Student Name: Lidya Daba

ID: ATR/9628/11

Lab Instructor: Mr. Bemnet


Due Date: March 11, 2020
Problem Description 1:
This problem asks me to make a variable called var_1 and save my age in it. Then I am required
to subtract 5 from the value of the variable. And also add 3 to the value of the variable.

Discussion:
In this program I have first initialize the variable to 20, which is my age, and then I subtract 5
from it. I also add 3 to the variable.

Pseudocode:
Initialize variable to 20

Subtract 5 from the variable

Add 3 to the variable

Source code:

Output:
Conclusion:
In this problem a have learned how to initialize a variable and operate elementary operations.

Problem Description 2:
I am required to clarify the difference between these declarations:

var_2 = 9*2

var_2 =9*2;

Discussion:
I have identified the difference of using and eliminating semicolon on a declaration by coding
the above codes on the app.

Source code and Output:

Conclusion:
Using semicolon at the end of statement helps to suppress the output. As we can see in the
above source code the first statement doesn't terminate with semicolon, therefore it shows the
output (it doesn't suppress it). In the second statement semicolon at the end, so it suppresses
the output and nothing is shown as an answer. All in all we terminate a statement using
semicolon if we don't want to display output for the statement.

Problem Description 3:
I am asked to create a variable called var_lb to store heaviness in pounds and change it to
kilogram. I am then required to give the result to another variable called var_kg. [Hint: 1 kg =
2.2 lb.]
Discussion:
I have first initialize arbitrary number to the variable (var_lb). Then I have changed the stored
pound to killogram using formula and then I assign the new value to other variable (var_kg)

Pseudocode:
Initialize a variable to 350
Change the value (pound) to kg and assign it to other variable

Source code:

Output:

Conclusion:
This problem changes the value of pound to kilogram. In order to do this I first assign arbitrary
value in pound to a variable and then changed it to kilogram and assigned it to other variable.

Problem Description 4:
This problem asks me to create a variable called var_far to save a temperature in Fahrenheit.
Then to change it to Celsius and give the result to another variable called var_cel. [Hint: C= (F-
32) x 5/9.]
Discussion:
As the above problem I have assigned arbitrary value, which is temperature in Fahrenheit, to a
variable(var_far) and changed to Celsius and assigned it to a new variable(var_cel).

Pseudocode:
Initialize a variable to 128
Change the value(Fahrenheit) in to Celsius and assign it to other variable

Source code:

Output:

Conclusion:
In this problem a temperature which was stored in a variable as Fahrenheit was converted in to
Celsius and assigned in a new variable.

Problem Description 5:
I am requested to write 5 different expressions that result in 9 by using only the numbers 2 and
3 and using operators and/or built-in functions.

Discussion:
As this problem requested I have written different expressions that result in 9 by using different
operators and/or built-in functions.
Source code and Output:

Conclusion:
This problem helped me to understand how to come up with a single result using different
expressions. I have also identified the use of some built-in functions.

You might also like