Changed file structure for LC13,14 and 15

This commit is contained in:
Louise Brown
2022-10-25 09:30:11 +01:00
parent a2c8695634
commit 7fd908108a
7 changed files with 26 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
// As we are using the function BEFORE it is actually written we need to provide the
// prototype so that the compiler can verify we are calling it correctly
void CalculateVolumeAndSA ( double Radius, double Length, double *Volume, double *SurfaceArea); // note the <20>*<2A>
// This is the main code for our application
int main()
{
double radius = 3.4, length = 7.3, volume, SurfaceArea;
CalculateVolumeAndSA(radius, length, &volume, &SurfaceArea);
printf("The volume is %f \n", volume);
printf( "The surface area is %f\n", SurfaceArea);
return 0;
}
// And here is our function
void CalculateVolumeAndSA ( double Radius, double Length, double *Volume, double *SurfaceArea) // note the <20>*<2A>
{
*Volume = M_PI * Radius * Radius * Length;
*SurfaceArea = ( 2 * M_PI * Radius * Radius * Length ) +( 2 * M_PI * Radius * Length );
}