1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
/* Name: Matt Hintzke
Date: 8/29/2011
Class: CptS 121
*/
#include <stdio.h>
#include <math.h>
#define PI 3.14159
#define HYDROGEN_MASS 1.008
#define PHOSPHORUS_MASS 30.97
#define OXYGEN_MASS 16
int main()
{
//Newton's Second Law
double mass, acceleration, force;
printf("Please enter the mass and acceleration to be used in Newton's Second Law of Motion:\n");
printf("Mass: ");
scanf("%f", &mass);
printf("Acceleration: ");
scanf("%f", &acceleration);
force = mass*acceleration;
printf("Force = mass * acceleration = %f * %f = %f\n\n", mass, acceleration, force);
//Volume of a Cylinder
double volume_cylinder, radius, height;
printf("Please enter the radius and height to find the volume of a cylinder.\n");
printf("Radius: ");
scanf("%f", &radius);
printf("Height: ");
scanf("%f", &height);
volume_cylinder = PI*radius*radius*height;
printf("\nThe volume of the cylinder is Volume = PI*r^2*h = %f\n\n", volume_cylinder);
//Character Encoding
char plain_character, encoded_character;
printf("Please input a single character: ");
scanf(" %c", &plain_character);
encoded_character = plain_character+4;
printf("The encoded character is '%c'\n\n", encoded_character);
//Height of a projectile
float height_proj, time, initial_height, initial_vel;
printf("Please enter the following information to find the height of a projectile: \n");
printf("Time(sec): ");
scanf("%f", &time);
printf("Initial Height: ");
scanf("%f", &initial_height);
printf("Initial Velocity: ");
scanf("%f", &initial_vel);
height_proj = -16*time*time+initial_vel*time+initial_height;
printf("The height of the projectile after %f seconds have passed is %f\n\n", time, height_proj);
//Current
float current, power, resistance;
printf("Please enter the following information to find the current of a circuit: \n");
printf("Power: ");
scanf("%f", &power);
printf("Resistance: ");
scanf("%f", &resistance);
current = sqrt((power/resistance));
printf("The current of the circuit is %f amps\n\n", current);
//General Equation
float y, x, z;
int a;
printf("For the equation y=(3/4)x-z/(a//%2)+PI please enter the following information: \n");
printf("x: ");
scanf("%f", &x);
printf("z: ");
scanf("%f", &z);
printf("a: ");
scanf("%d", &a);
y=(3/4)*x-(z/(a%2))+PI;
printf("%f %f %d", x, z, a);
printf("For the given equation y = %f", y);
return 0;
}
|