03_FundamentalsB(Sep.16)

# 03_FundamentalsB(Sep.16) - on a spring with no external...

This preview shows pages 1–5. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
APSC160 Fundamentals B Sep.16-2010 Q5 (volume_of_shpere.c) /* * Author: Ed Knorr * Date: September 16, 2010 * Purpose: Compute the volume of a sphere. The user is prompted for the * radius (in cm.), and the computed answer (in cubic cm.) is * displayed on the screen. */ #define _CRT_SECURE_NO_WARNINGS /* optional, gets rid of warning message */ #include <stdio.h> #include <stdlib.h> #include <math.h> #define PI acos(-1.0) /* accurate constant for PI */ int main( void ) { double radius; double volume; printf( "Enter radius of sphere (in cm.): " ); scanf( "%lf", &radius ); volume = 4.0 / 3.0 * PI * pow(radius, 3.0); printf( "Volume of sphere = %f cubic cm.\n", volume ); system( "PAUSE" ); return 0; }
APSC160 Fundamentals B Sep.16-2010 Q6 (oscillating_mass_particle.c ) /* * Author: Ed Knorr * Student #: 12345678 * Lab Section: L1Y * Date: September 16, 2010 * Purpose: Compute the position of a particle of mass oscillating
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: * on a spring with no external forces at the given time. * The user is prompted for the initial position, initial * velocity, and a time. We'll assume a mass of 2 units * and a spring constant of 0.5 */ #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> #include <math.h> #define MASS 2 #define STIFFNESS 0.5 #define FREQ sqrt( STIFFNESS / MASS ) int main(void) { double initPosition; double initSpeed; double initTime; double computedPosition; printf("Enter the initial position (in metres): "); scanf("%lf", &initPosition); printf("Enter the initial speed (in metres/sec): "); scanf("%lf", &initSpeed); printf("Enter a time (in seconds): "); scanf("%lf", &initTime); computedPosition = initPosition * cos(FREQ * initTime) + initSpeed / FREQ * sin(FREQ * initTime); printf("The position of the particle is: %.3f metres\n", computedPosition); system("PAUSE"); return 0; }...
View Full Document

{[ snackBarMessage ]}

### Page1 / 5

03_FundamentalsB(Sep.16) - on a spring with no external...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online