{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# Lab6 - Tao Lin Lab#6 EE140/Lab#6 Question#1 Tao Lin/A...

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

Tao Lin Lab#6 EE140 //---------------------------------------------------------------- //Lab#6 Question#1 Tao Lin //A program that ask users for velocity and angle. The program calculate //time, distance, and height using functions and display the results //on the screen. //------------------------------------------------------------------ #include <stdio.h> #include <math.h> double const pi=3.1415926,g=9.8; //function time double time( double velocity, double angle) { double t; double radian=angle/180*pi; //covert degree into radian t=2*velocity*sin(radian)/g; return t; } //function distance double distance( double velocity, double angle) { double d; double radian=angle/180*pi; d=velocity*velocity*sin(2*radian)/g; return d; } //function height double height( double velocity, double angle) { double h; double radian=angle/180*pi; h=velocity*velocity*sin(radian)/g; return h; } int main( void ) { double velocity, angle,Time,Distance,Height; printf( "Enter velocity: " ); scanf( "%lf" ,&velocity); printf( "Enter angle: " ); scanf( "%lf" ,&angle); //call functions Time=time(velocity, angle); Distance=distance(velocity,angle); Height=height(velocity,angle);

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

View Full Document
printf( "The time is: %f\nThe distance is: %f\nThe height is: %f\n\n" ,Time,Distance,Height); return 0; }
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}