Algorithm and Flowcharting
Algorithm and Flowcharting
BCS14
Question 1:
Algorithm
1. initialize variables: num1 and num2.
2. Output "Enter the first number:"
3. Input value to num 1.
4. Output "Enter the second number:"
5. Input value to num 2.
6. Output the sum of num1 and num2.
7. Output the difference of num1 and num2.
8. Output the product of num1 and num2.
9. Output the quotient of num1 and num2.
Pseudocode
1. var num1, num2;
2. out: "Enter the first number: ";
3. in: num1;
4. out: "Enter the second number: "
5. in: num2;
6. out:"sum: " num1+num2 "\n";
7. out:"difference:" num1-num2 "\n";
8. out:"product:" num1*num2 "\n";
9. out: "quotient:" num1/num2 "\n";
Flowchart:
Question 2:
Algorithm
1. Initialize variables: midterm, final, and average.
2. Output "Enter midterm grade: ".
3. Input variable to midterm.
4. Output "Enter final grade: ".
5. Input variable to final.
6. Give value to average where the value is (num1+num2)/2.
7. Output "Average grade: " then output the average value.
8. If average is more than 85, output "Remarks: Passed".
9. Else, output "Remarks: Failed".
Pseudocode
1. var midterm, final, average;
2. out: "Enter midterm grade: ";
3. in: midterm;
4. out: "Enter final grade: ";
5. in: final;
6. average = (midterm+final)/2;
7. out: "Average Grade: " average "\n";
8. if: average>=85, out: "Remarks: Passed";
9. else: out: "Remarks: Failed";
Flowchart: