My work book final, Exercises of Computer Programming

workbook for Assembly language vc++ and java

Typology: Exercises

2015/2016

Uploaded on 10/19/2016

Mayee_1990
Mayee_1990 🇵🇭

1 document

1 / 109

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Republic of the Philippines
SULTAN KUDARAT STATE UNIVERSITY
Kalamansig Campus
Kalamansig, Sultan Kudarat
Compiled by:
MAILYNE V. BACONGCO, CpE
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Partial preview of the text

Download My work book final and more Exercises Computer Programming in PDF only on Docsity!

Republic of the Philippines SULTAN KUDARAT STATE UNIVERSITY Kalamansig Campus Kalamansig, Sultan Kudarat

Compiled by:

MAILYNE V. BACONGCO, CpE

SKSU Vision

A trailblazer in art, science and technology in the region.

SKSU Mission

The University shall primarily provide advanced instruction and professional training in science and technology, agriculture, fisheries, education and other relevant fields of study. It shall also undertake and extension services, and provide progressive leadership in its areas of specialization.

Activity 3: Supply the actual binary bits Activity 4: Supply the normalized value and resulting exponent Activity 5: Supply the complete binary Practice and Application Activity 6: Do it yourself Closure Activity 7: Show Me the Value Lesson 4: Addition and Subtraction Instructions Introduction Learning Outcome Activating Prior Knowledge Activity 1: Valid or Invalid Setting the Context Activity 2: Valid or Invalid Activity 3: Carry or No carry Activity 4: Zero or Not Zero Activity 5: Positive or Negative Activity 6: Carry, Sign, and Zero Practice and Application Activity 7: Do it yourself Lesson 5: Direct Memory Operands Introduction Learning Outcome Activating Prior Knowledge Activity 1: Valid or Invalid Activity 2: Valid or Invalid Setting the Context Activity 3: Hexadecimal Value Activity 4: Hexadecimal Value Activity 5: Hexadecimal Value Activity 6: Hexadecimal Value Practice and Application Activity 7: Do it yourself Part II: VC++ Lesson 6: Introduction to Hardware and Software Introduction Learning Outcome Activating Prior Knowledge Activity 1: H or S Setting the Context Activity 2: Guess Me Activity 3: 8-bit to decimal and hex Activity 4: 16-bit to decimal and hex Activity 5: ASCII codes in decimal, hex and binary Activity 6: Solve for x Practice and Application

Activity 7: Interpretation Lesson 7: A First Look at a C++ Program Introduction Learning Outcome Activating Prior Knowledge Activity 1: True or False Setting the Context Activity 2: Identification Activity 3: True or False Activity 4: Always, Sometimes, or Never Activity 5: Fill in the Blank Activity 6: Encircle Me Activity 7: True or False Practice and Application Activity 8: Do it yourself Lesson 8: Variables and Constants Introduction Learning Outcome Activating Prior Knowledge Activity 1: Encircle Me Setting the Context Activity 2: True or False Practice and Application Activity 3: Do it yourself Lesson 9: Arithmetic Expressions Introduction Learning Outcome Activating Prior Knowledge Activity 1: Find the Output Setting the Context Activity 2: Fix the Bug Activity 3: True or False Activity 4: Fill in the Blank Practice and Application Activity 5: Write a program Lesson 10: Arrays, apvector and apmatrix Classes Introduction Learning Outcome Activating Prior Knowledge Activity 1: True or False Setting the Context Activity 2: Valid or Invalid Practice and Application Activity 3: Test my Program Activity 4: Fix the Bug

Lesson

BINARY AND HEXADECIMAL INTEGERS

Introduction

Every number system uses positional notation i.e., each position in which a digit is written has a different positional value. Each position is power of the base, which is 2 for binary number system, and these powers begin at 0 and increase by 1.

Hexadecimal number system uses base 16. The digits range from 0 to 15. By convention, the letters A through F is used to represent the hexadecimal digits corresponding to decimal values 10 through 15. Main use of hexadecimal numbers in computing is for abbreviating lengthy binary representations. Basically hexadecimal number system represents a binary data by dividing each byte in half and expressing the value of each half-byte.

Learning Outcomes

At the end of the lesson the students can solved the following types of problems: a. Identify positional values for an 8-bit binary numbers; b. Write the equivalent binary and hexadecimal representation of decimal number; c. Convert decimal to binary, binary to decimal, hexadecimal to decimal, binary to hexadecimal, and hexadecimal to binary; and d. Solved any number system to its desired base.

Activating Prior Knowledge

Directions: Fill the missing positional values for an 8-bit binary number, where all bits are set on. Bit number 7 was already done for you.

Bit Value 1 1 1 1 1 1 1 1 Position value as a power of base 2

Bit number 7 6 5 4 3 2 1 0

Fill the Box

Part I

Directions: Complete the table by writing the equivalent binary and hexadecimal representation of decimal number. Decimal number 2 was already done for you.

Decimal Number Binary Representation Hexadecimal Representation 0 1 2 0010 2 3 4 5 6 7 8 9

Setting the Context

Directions: Write each of the following decimal numbers in binary:

  1. 2 = 6. 12 =
  2. 7 = 7. 15 =
  3. 5 = 8. 16 =
  4. 8 = 9. 20 =
  5. 9 = 10. 27 =

Complete Me

Conversion: Decimal to Binary

  1. 000Bh = 10. 0063h =

Directions: Write each of the following Hexadecimal numbers in Decimal:

  1. 00D5h = 6. 041Ch =
  2. 002Fh = 7. 0B30h =
  3. 0110h = 8. 06DFh =
  4. 0216h = 9. 1AB6h =
  5. 004Bh = 10. 0A63h =

Comprehension Check

Directions: Convert the following number system to its desired base. Number 1 is provided for you. Write your Solution and answer in the space provided.

  1. 37410 to base 2

Conversion: Hexadecimal to Decimal

Problem Solving

Solution: 374/2 = 0 Answer: 101110110 2 187/2 = 1 93/2 = 1 44/2 = 0 23/2 = 1 11/2 = 1 5/2 = 1 2/2 = 0 ½ = 1

  1. 37410 to base 8
  2. 75348 to base 2
  3. CAFE 16 to base 10

Solution:

Solution:

Solution:

c. 10110 – 01101 =

d. 11111 – 01011 =

  1. Do the hexadecimal arithmetic:

a. 82CD + 1982 = c. FB28 – 3254 =

b. E2C + A31 = d. E2C – A31 =

  1. The integers in the following computations are indicated in hexadecimal, but represent 32 – bit two’s complement binary numbers. Perform the operations and indicate if overflow occurs and why. (If overflow occurs the result is invalid, but show it anyway.)

a. BBCA270C d. 5FCA +AE223464 +AE

b. E3BA265F e. 80000000

  • E045B9A9 +7FFFFFFF

a. E9B20F5D f. 6D4AFBC +FE605C8D +F89ABCDE

Closure

Directions:

  1. Write decimal numbers from 1 to 100 and convert it into binary.
  2. From the converted binary convert it into hexadecimal.
  3. Discuss your observation in converting binary and decimal numbers.
  4. Use extra sheet of paper for all of your answer.

Individual Work

Lesson

SIGNED INTEGER

Introduction

In mathematics, the additive inverse of a number n is the value, when added to n, produces zero. Programs often include both subtraction and addition operations, but internally, the CPU really only performs addition. To get around this restriction, the computer uses the additive inverse. When subtracting A-B, the CPU instead performs A+ (-B).

Learning Outcome At the end of the lesson the students can solved the following types of problems: a. write the equivalent negative binary numbers of positive numbers; b. write signed decimal integers in 8-bit binary notation; c. identify the valid 16-bit signed decimal integers; and d. perform subtraction of unsigned decimal number.

Activating Prior Knowledge

Directions: Write the equivalent negative binary number of the following positive number. Number 1 was already done for you.

1. Number +53 00110101 Reverse the bits 11001010 Add 1 1 Number - 53 11001011

Number +36 00110101 Reverse the bits 11001010 Add 1 1 Number -

My negative side

Directions: Match column A to column B by drawing a line connecting to its equivalent decimal. Number 1 was already done for you provided.

Column A Column B

  1. 11111111 1. +
  2. 11110000 2. -
  3. 10000000 3. +
  4. 10000001 4. -
  5. 00001111 5. -
  6. 10101111 6. -
  7. 11111100 7. -
  8. 01010101 8. -

Directions: Which of the following integers are valid 16-bit signed decimal integers? Write your answer in the box provided. (Indicate V=valid, I=invalid)

Find my match

Valid or Invalid

Directions: Indicate the sign of each of the following 16-bit hexadecimal integers: Write your answer in the box provided. (indicate P=positive, N=negative)

  1. 7FB9h =
  2. 8123h =
  3. 0D000h =
  4. 649Fh =

Directions: Write each of the following signed decimal integers as a 16-bit hexadecimal value. Write your answer in the box provided.

  1. -42 5. -

Positive or Negative

16 - bit Hexadecimal

  1. 20 – 40 (2 digits)
  2. 1200 – 250 (4 digit)

Solution:

Solution:

Closure

Directions: Perform the subtraction with the following unsigned binary numbers by taking the 2’s complement of the subtrahend. Write your answer in the box provided.

  1. 11010 – 10000 (5 digits)
  2. 100 – 110000 (6 digits)

Individual Work

Solution:

Solution: