Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

ICSC 102 - COMPUTER PROGRAMMING 1

GENEERATION OF PROGRAMMING LANGUAGES

Name of Student: ALOROY, STONE JAMES B. Activity Title: ACTIVITY 2.1 –Algorithms,
Pseudocode, and Flowchart
Year and Section: 1 BSIT- FATIMA Date Submitted:

INSTRUCTIONS

ACTIVITY 2.1 –Algorithms, Pseudocode, and Flowchart


Instructions:
1. Write an algorithm, pseudocode, and draw a flowchart to find the GCD and LCM of two numbers.
2. Write an algorithm, pseudocode, and draw a flowchart to find that will input length in centimeter
and convert it to meter and kilometers.
3. Write an algorithm, pseudocode, and draw a flowchart to find the sum, difference, quotient,
product of the two given numbers.
Note:
4. Use the activity sheet provided in assignment section of the subject in the LMS.
5. Submit the activity in assignment in printed format.

Answers:

1.

A. Algorithm

Algorithm: Find GCD and LCM of Two Numbers

Step 1: Input two integer numbers, num1 and num2.

Step 2: Calculate the absolute values of num1 and num2 to ensure positive integers.

Step 3: Calculate the GCD using the Euclidean algorithm. - Initialize variables a and b with the
absolute values of num1 and num2. - While b is not equal to 0, do the following: - Calculate
remainder = a % b. - Set a = b. - Set b = remainder. - GCD is now stored in variable a.

Step 4: Calculate the LCM using the formula LCM = (num1 * num2) / GCD.

Step 5: Output the GCD and LCM.


B. Pseudocode
C. Flowchart

2.
A. Algorithm
B. Pseudocode

C. Flowchart
3.A. Algorithm

B. Pseudocode
C. Flowchart

You might also like