move exercises and lectures into subfolders

This commit is contained in:
2023-10-15 15:34:53 +01:00
parent 775b4bd643
commit 74092a17aa
177 changed files with 0 additions and 0 deletions

17
Lectures/LC20/AreaFunc.c Normal file
View File

@@ -0,0 +1,17 @@
#include <stdio.h>
#include <math.h>
float CalculateAreaOfCircle ( float radius )
{
float area;
area = M_PI * radius * radius ;
return (area) ;
}
float CalculateSurfaceAreaOfCylinder ( float radius, float length )
{
float area;
area = 2.0 * ( M_PI * radius * radius ) + ( M_PI * 2.0 * radius * length ); // two ends + side
return (area) ;
}

2
Lectures/LC20/AreaFunc.h Normal file
View File

@@ -0,0 +1,2 @@
float CalculateAreaOfCircle ( float radius );
float CalculateSurfaceAreaOfCylinder ( float radius, float length );

34
Lectures/LC20/Main.c Normal file
View File

@@ -0,0 +1,34 @@
#include <stdio.h>
#include <stdlib.h>
#include"AreaFunc.h"
/* Show use of function */
int main (void)
{
// Declare variables - no need to initialise as values will be read in / calculated
float rad, len, Area, SurfaceArea;
// Prompt for and obtain value
printf ("Please enter the raduis of the circle: ");
scanf ("%f", &rad);
printf ("Please enter the length of the cylinder: ");
scanf ("%f", &len);
// Calculate the area of the circle
Area = CalculateAreaOfCircle(rad);
// And display the answer on the screen
printf ("The area of a circle of radius %f is %f\n", rad, Area );
// Calculate the surface area of the cylinder
SurfaceArea = CalculateSurfaceAreaOfCylinder(rad, len);
// And display the answer on the screen
printf ("The surface area of a cylinder of radius %f and length %f is %f\n", rad, len, SurfaceArea );
// All done
return 0;
}