COMPUTER-PROGRAMMING-FUNDAMENTAL

You might also like

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

COMPUTER PROGRAMMING FUNDAMENTAL

( IT 325)

BSEnE -3A

CASCATO, ALEN MAE C.

EXAMINADA, KYNN AIELL S.

PADEN, KAYE O.

JUNE 3, 2024
TABLE OF CONTENTS

RATIONALE ……………………………………. I

ALGORITHM ………………………………......... II

PSEUDOCODE ……………………………………. III

FLOWCHART …………………………………… IV

SOURCE CODE …………………………………… V

SAMPLE OUTPUT …………………………………… VI

DOCUMENTATION …………………………………… VII


RATIONALE
Title: ALGORITHM

Steps:
1. Start
2. Input: Read the radius r of the circle
3. Process: Calculate the area using the formula Area = π x r²
4. Output: Display the area of the circle
5. End

Detailed Algorithm

Tittle: ALGORITHM

1. Start
2. Input:
- Read the radius r of the circle
3. Process:
- Calculate the area using the formula:
- Area = π x r²
4. Output:
- Display the area of the circle
5. End
Flowchart
Title: PSEUDOCODE

Pseudocode Steps:
1. START
2. Input: radius r
3. Process: Calculate area using the formula Area = π x r²
4. Output: the area
5. END

Detailed Pseudocode

Title: PSEUDOCODE
1. START
2. Input: radius r
3. Process:
- Calculate area using the formula:
- Area = π x r²
4. Output: the area
5. END

Pseudocode:

Begin
Initialize mass (m), volume (v), density
Read mass (m), volume (v)
Compute density as density = mass(m)/volume (v)
Write density
End
Source Code

# Program to calculate the area of a circle


# Import the math module to access the value of pi
import math
def calculate_area(radius):
"""
Function to calculate the area of a circle
given the radius.
"""
# Area calculation using the formula: Area = pi * r^2
area = math.pi * radius ** 2
return area

# Main function to execute the program


def main():
# Input: Read the radius from the user
radius = float(input("Enter the radius of the circle: "))

# Process: Calculate the area


area = calculate_area(radius)

# Output: Display the area


print(f"The area of the circle with radius {radius} is: {area:.2f}")

# Execute the main function


if __name__ == "__main__":
main()

Sample Output

# Define pi (optional, most languages have a built-in constant for pi)


PI = 3.14159

# Get the radius from the user


radius = float(input("Enter the radius of the circle: "))

# Calculate the area


area = PI * radius * radius

# Print the result


print("The area of the circle is:", area)

You might also like