COURSE: ITE 001 PROGRAM: BSCS PERIOD: Prelims DATE: July 08, 2019
NAME: RIVADENERA, Marjorie Anne ASSESSMENT: Assignment 1st Semester
SECTION: CS11FA1 TOPIC: Flowcharts S.Y. 2019-2020
Create a flowchart, pseudo code, and source code that will solve the following machine
problems:
1. Find the area of a right triangle using the Heron’s Formula.
A. Flowchart
START
a = 0, b = 0, c = 0
area = 0, s = 0
INPUT
(a,b,c)
s = (a + b + c)/2
area = sqrt(s*(s-a)*(s-b)*(s-c))
OUTPUT
(area)
END
B. Pseudo Code
Start
Initialize a, b, c, s, area
Read a, b, c
Compute
s = (a + b + c)/2
area = sqrt(s*(s-a)*(s-b)*(s-c))
Write
area
End
C. Source Code
#include <iostream>
#inclue <cmath>
using namespace std;
main(){
float a, b, c, s, area;
cout << “Enter the first side of a triangle: ” ;
cin >> a ;
cout << “Enter the second side of a triangle: ” ;
cin >> b ;
cout << “Enter the third side of a triangle: ” ;
cin >> c ;
s = (a + b + c)/2 ;
area = sqrt(s*(s-a)*(s-b)*(s-c)) ;
cout << “The area of the triangle is ” << area << endl;
}
2. Find the perimeter of a square from its area.
A. Flowchart
START
perimeter
area
INPUT
(area)
perimeter = 4*sqrt(area)
OUTPUT
(perimeter)
END
B. Pseudocode
Start
Initialize perimeter, area
Read area
Compute
perimeter = 4*sqrt(area)
Write
perimeter
End
C. Source Code
#include <iostream>
#include <cmath>
using namespace std;
main(){
float area, perimeter ;
cout << “Enter the area of a square: ” ;
cin >> area ;
perimeter = 4*sqrt(area) ;
cout << “The perimeter of the square is ” << perimeter ;
}