computing
computing
2. Techniques in Programming
Programming techniques help write effective and efficient code. Here are the key
techniques:
3. Errors in Programming
Errors in programming can be categorized into the following types:
1. Start
2. Prompt the user to enter the recipient’s email address.
3. Verify if the email address is valid.
○ If invalid, display "Invalid Email Address" and stop.
4. Prompt the user to enter the subject of the email.
5. Prompt the user to write the content of the email.
6. Ask if the user wants to attach a file.
○ If yes, prompt for file selection and attach it.
7. Confirm with the user before sending.
8. Send the email.
9. Display "Email sent successfully."
10. End
Flowchart
Here is a flowchart to represent the algorithm visually:
yaml
Copy code
+---------------------+
| Start |
+---------------------+
|
v
+---------------------+
| Enter recipient's |
| email address |
+---------------------+
|
v
+---------------------+
| Validate email? |
+---------------------+
/ \
Yes No
| |
v v
+-------------------+ +------------------+
| Enter subject | | Display "Invalid |
| and message | | Email" |
+-------------------+ +------------------+
|
v
+------------------------+
| Attach file? |
+------------------------+
/ \
Yes No
| |
+-----------------+ |
| Attach file | |
+-----------------+ |
\ /
v
+------------------------+
| Confirm and send email |
+------------------------+
|
v
+------------------------+
| "Email sent successfully" |
+------------------------+
|
v
+-------+
| End |
+-------+
Example:
sql
Copy code
+--------+
| Start |
+--------+
○
2. Diamond: Represents a Decision or condition (e.g., "Is the email valid?").
Example:
lua
Copy code
+------------------+
| Is email valid? |
+------------------+
/ \
Yes No
○
3. Rectangle: Represents a Process or step (e.g., "Write the email content").
Example:
diff
Copy code
+------------------+
| Write content |
+------------------+
○
4. Arrow: Shows the flow or direction of steps in a flowchart.
Example:
sql
Copy code
+--------+ ---> +--------+
| Start | | Process|
+--------+ +--------+
○
5. Parallelogram: Represents an Input/Output operation (e.g., "Enter recipient's
email").
Example:
diff
Copy code
+------------------+
| Enter recipient's|
| email |
+------------------+
mathematica
Copy code
+------------------+
| Start | <-- Oval
+------------------+
|
v
+------------------+
| Enter recipient's| <-- Parallelogram (Input)
| email address |
+------------------+
|
v
+------------------+
| Is email valid? | <-- Diamond (Decision)
+------------------+
/ \
Yes No
| |
v v
+------------------+ +------------------+
| Enter subject | | Display "Invalid|
| and content | | Email Address" |
+------------------+ +------------------+
| |
| v
| +------------------+
| | End | <-- Oval
| +------------------+
|
v
+------------------+
| Attach a file? | <-- Diamond (Decision)
+------------------+
/ \
Yes No
| |
v v
+------------------+ +------------------+
| Attach the file | | Confirm email |
+------------------+ | and send |
\ / +------------------+
\ / |
\ / v
+------------------+
| Send the email |
+------------------+
|
v
+------------------+
| Email sent |
| successfully |
+------------------+
|
v
+----------------+
| End | <-- Oval