Prac 2
Prac 2
2
SLOs Mapped 8.3.2, 9.1.1,9.1.2,9.1.3,9.1.5,9.2.2,9.2.3,9.2.4
Practical Activity To find the area of a triangle, parallelogram, rhombus and trapezoid
Equipment Computer
Software Dev C++
Practical No 2
Topic 9: Fundamental of input and output data handling in C
Objective:
Students will be able to
use the arithmetic operators and input output data handling in C language to solve the given
arithmetic problem.
Note: You can use any compiler for program execution.
Area of Triangle
Sample Input Process Sample Output
Base = 8
Area = 0.5 * base * height Area of Triangle = 38
Height = 9.5
Area of Parallelogram
Sample Input Process Sample Output
Height = 5
Area = base * height Area of Parallelogram = 40
Base = 8
Area of Rhombus
Sample Input Process Sample Output
Diagonal1 = 4.2
Area = 0.5 * diagonal1 * diagonal2 Area of Rhombus = 7.56
Diagonal2 = 3.6
Area of Trapezoid
Sample Input Process Sample Output
Base1 = 6.5
Base2 = 5.3 Area = 0.5 * height * (base 1 + base 2) Area of Trapezoid = 23.6
Height = 4
3
Computer Science Practical: X
Area of Triangle
Algorithm Flowchart
Step1: Start
Step4: Stop
Code Output
#include <stdio.h>
#include <math.h>
int main ()
{
float base, Area, height;
return 0;
4
Computer Science Practical: X
Area of Parallelogram
Algorithm Flowchart
Step1: Start
Area=b*h
Step3: Output Area
Step4: Stop
Code Output
#include <stdio.h>
#include <math.h>
int main ()
{
float base, Area, height;
return 0;
5
Computer Science Practical: X
Area of Rhombus
Algorithm Flowchart
Step1: Start
Let the d1 is 4.2 and d2 is 3.6
Step2: Calculate the Area
Area=0.5*d1*d2
Step3: Output Area
Step4: Stop
Code Output
#include <stdio.h>
#include <math.h>
int main ()
{
float Diagonal1, Diagonal2, Area;
return 0;
6
Computer Science Practical: X
7
Computer Science Practical: X
Area of Trapezoid
Algorithm Flowchart
Step1: Start
Let the b1 6.5 is and b2 is 5.3 and h is4
Step2: Calculate the Area
Area=0.5*b1*b2*h
Step3: Output Area
Step4: Stop
Code Output
#include <stdio.h>
#include <math.h>
int main ()
{
float Base1, Base2, Height, Area;
return 0;