Module 1 Lesson 2 - Abstraction
Module 1 Lesson 2 - Abstraction
Download and install the DevC++ 5.11 from the Internet or you may
access the BTC 216 – Computer Programming class of the University Virtual
Learning Environment where an installer is already uploaded.
1|Page
BTC 216 – Computer Programming
2|Page
BTC 216 – Computer Programming
In order for us to have the same reference during class discussion. We are
going to set the line numbers. To access and activate this, click on the Tools
menu and then select the Editor options.
After clicking the Editor Options option, click on the font tab. Click the
checkbox with Line numbers option. You can also adjust the font size by
adjusting the Size option. After you have check the Line number checkbox or set
the font size, you may now click the Ok option.
3|Page
BTC 216 – Computer Programming
4|Page
BTC 216 – Computer Programming
2) The cin and extraction (>>)operator. This is use to input the value or
data you entered from the keyboard to be stored in an already declared
variable. The format is: cin>>variable;
In figure, line 8 is the variable declaration with variable name number. This
variable holds or stores any integer value that will be entered by the user. Line
14 will accept any integer number as input from the user and store the input value
in the variable number. Line 16 displays on your computer screen the integer
number you enter which was stored in the variable number in line 14.
5|Page
BTC 216 – Computer Programming
Line 8 is a variable declaration that will store any numeric values entered
by the user as temperature value while Line 9 is a variable declaration
using the data type string for the variables firstname and lastname. Lastly
Line 20 will display the values entered by the user.
6|Page
BTC 216 – Computer Programming
7|Page
BTC 216 – Computer Programming
Example 3
8|Page
BTC 216 – Computer Programming
Example 4
A Fahrenheit temperature can be converted to an equivalent Celsius
temperature according the following formula: Celsius = (5/9 x (Fahrenheit –
32.0)). Write a program that will read in a Fahrenheit temperature and then output
the equivalent Celsius temperature.
9|Page
BTC 216 – Computer Programming
Example 5
A class has four tests in one term. Write a program that will read student’s
test scores and output the student’s average exam score.
10 | P a g e
BTC 216 – Computer Programming
11 | P a g e