Prac 1
Prac 1
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 volume of cube, cylinder or sphere
Equipment Computer
Software Dev C++
Practical No 1
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.
Volume of Cube
Sample Input Process Sample Output
Length = 4 Volume = length * length * length Volume of Cube = 64
Volume of Cylinder
Sample Input Process Sample Output
Height = 5
Volume = π * radius * radius * height Volume of Cylinder = 1005.12
Radius = 8
Volume of Sphere
Sample Input Process Sample Output
4
Radius = 6.5 Volume = 𝜋𝑟 3 Volume of Cube = 1150.1295
3
Fill the sections on the pages below as evidence of the practical activity.
Computer Science Practical: X
Volume of Cube
Algorithm Flowchart
Step1: Start
Let the length of one side of cube is 4
Step2: Calculate the volume
Volume=𝑙3
Step3: Output Volume
Step4: Stop
Code Output
#include <stdio.h>
int main ()
{
float length, volume;
printf ("enter the lenght:");
scanf ("%f", & lenght);
volume=(lenght*lenght*lenght);
printf ("volume of cube is: %.2f", volume);
return 0;
}
2
Computer Science Practical: X
Volume of Cylinder
Algorithm Flowchart
Step1: Start
Let radius is 8 and height is 5 and π is 3.14
Step2: Calculate the volume
Volume=πr2ℎ
Step3: Output Volume
Step4: Stop
Code Output
#include <stdio.h>
#include <math.h>
#define PI 3.14159
int main ()
{
float radius, Volume, Height;
printf ("enter the Height:");
scanf ("%f", & Height);
3
Computer Science Practical: X
Volume of Sphere
Algorithm Flowchart
Step1: Start
Let radius is 6.5 and π is 3.14
Step2: Calculate the volume
4
Volume= 𝜋𝑟 3
3
Step3: Output Volume
Step4: Stop
Code Output
#include <stdio.h>
#include <math.h>
#define PI 3.14159
int main ()
{
float radius, volume;