0% found this document useful (0 votes)
24 views4 pages

Prac 2

The document outlines a practical activity for students to calculate the areas of various geometric shapes using C programming. It includes algorithms, flowcharts, and sample code for calculating the area of a triangle, parallelogram, rhombus, and trapezoid. The objective is to enhance students' understanding of input and output data handling in C language.

Uploaded by

Dark Skies
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views4 pages

Prac 2

The document outlines a practical activity for students to calculate the areas of various geometric shapes using C programming. It includes algorithms, flowcharts, and sample code for calculating the area of a triangle, parallelogram, rhombus, and trapezoid. The objective is to enhance students' understanding of input and output data handling in C language.

Uploaded by

Dark Skies
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Name: Bilal Ahmed Khan Grade: XA

SLO No 9.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.
Fill the sections below as evidence of the practical activity.
Algorithm
Area of Triangle Area of Parallelogram
Step 1: Start Step 1: Start
Step 2: Input b, h Step 2: Input b, h
Step 3: A=(1/2)*b*h Step 3: A=b*h
Step 4: Print A Step 4: Print A
Step 5: Stop Step 5: Stop

Area of Rhombus Area of Trapezoid

3
Computer Science Practical: X

Name: Bilal Ahmed Khan Grade: XA


Step 1: Start Step 1: Start
Step 2: Input d1, d2 Step 2: Input b1, b2, h
Step 3: A=(1/2)*d1*d2 Step 3: A=(1/2)*( b1+b2)*h
Step 4: Print A Step 4: Print A
Step 5: Stop Step 5: Stop

Flowchart
Area of Triangle Area of Parallelogram

Start

Input b, h

A=b*h

Print A

Stop

Area of Rhombus Area of Trapezoid

4
Computer Science Practical: X

Name: Bilal Ahmed Khan Grade: XA

Start Start

Input d1, d2 Input b1, b2, h

A=(1/2)*d1*d2 A=(1/2)*(b1+b2)*h

Print A Print A

Stop Stop

Program Coding
Area of Triangle Area of Parallelogram
#include<stdio.h> #include<stdio.h>
int main() int main()
{ {
float b, h, A; float b, h, A;
printf("Enter base= "); printf("Enter base= ");
scanf("%f", &b); scanf("%f", &b);
printf("Enter height= "); printf("Enter height= ");
scanf("%f", &h); scanf("%f", &h);
A=0.5*b*h; A=b*h;
printf("Area= %f", A); printf("Area= %f", A);
} }
Area of Rhombus Area of Trapezoid
#include<stdio.h> #include<stdio.h>
int main() int main()
5
Computer Science Practical: X

Name: Bilal Ahmed Khan Grade: XA


{ {
float d1, d2, A; float b1, b2, h, A;
printf("Enter diagonal 1= "); printf("Enter base 1= ");
scanf("%f", &d1); scanf("%f", &b1);
printf("Enter diagonal 2= "); printf("Enter base 2= ");
scanf("%f", &d2); scanf("%f", &b2);
A=0.5*d1*d2; printf("Enter height= ");
printf("Area= %f", A); scanf("%f", &h);
} A=0.5*(b1+b2)*h;
printf("Area= %f", A);
}
Program Output
Area of Triangle Area of Parallelogram

Area of Rhombus Area of Trapezoid

You might also like