03_FundamentalsB(Sep.16)

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

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

View Full Document Right Arrow Icon
Background image of page 1

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

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3

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

View Full DocumentRight Arrow Icon
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; }
Background image of page 4
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
Background image of page 5
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

This note was uploaded on 11/12/2010 for the course APSC 160 APSC 160 taught by Professor Charles during the Spring '10 term at UBC.

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 Right Arrow Icon
Ask a homework question - tutors are online