This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: MAE 9: Homework #1, Fall 2005 Due on Thursday, October 6, Turnin time from 9:00am10:00pm (a) prints your name three times on the terminal screen; each time the name should be printed in a separate (consecutive) line. (b) prints your name three times on the terminal screen, all appearing in the same line; leave two empty spaces between each writing of the name in this line. Leave one empty line at the beginning of the output, one empty line between parts (a) and (b), and two empty lines at the end. Also, insert Part (a) and Part (b) designations as shown below. #include <stdio.h> main() { printf("\n"); printf("Part (a):\n\n"); printf("Caryn Urbanczyk\n"); printf("Caryn Urbanczyk\n"); printf("Caryn Urbanczyk\n\n"); printf("Part (b):\n\n"); printf("Caryn Urbanczyk Caryn Urbanczyk Caryn Urbanczyk\n\n"); } #include <stdio.h> main(void) { printf("\n\n"); printf("Part (a):\n\n"); int k; for(k=0; k<3; k++) { printf("Caryn Urbanczyk\n"); } printf("\n"); printf("Part (b):\n\n"); int s; for(s=0; s<3; s++) { printf("Caryn Urbanczyk "); } printf("\n\n"); } Part (a): Caryn Urbanczyk Caryn Urbanczyk Caryn Urbanczyk Part (b): Caryn Urbanczyk Caryn Urbanczyk Caryn Urbanczyk MAE 9: Homework #2, Fall 2005 Due on Thursday, October 13, Turnin from 9:00am  10:00pm Compute the area (A) and the volume (V) of a sphere with radius R=2.0, R=2.1, R=2.2, ... , R=4.0 . Compute also the total area (TA) and the total volume (TV) of all these spheres together. Finally, compute the average radius, average area, and average volume of considered spheres (R_av, A_av, V_av). Define PI by using #define and use a forloop to repeat calculations for different values of R. (Use PI=3.141593 and recall the elementary formulas A=4*PI*R*R and V=4*PI*R*R*R/3). For each sphere, print in one line Sphere (k) Radius = "number" Area = "number" Volume = "number" At the end, in a separate line, print Total Area = "number" Total Volume = "number" In a separate line print also: Average Radius = "number" Average Area = "number" Average Volume ="number" Use the output specifier 2d for k (k is a sequential number of the sphere), 4.1f for R, and 7.3f for A, V, TA, TV, R_av, A_av, V_av. #include<stdio.h> #include<math.h> #define PI 3.141593 int main(void) { printf("\n\n"); int k; double a=0.0,v=0.0,ta=0.0,tv=0.0,r=1.9,tr=0.0,r_av,a_av,v_av; for(k=0;k<=20;k++) { r += 0.1; a=4*PI*r*r; v=4./3*PI*r*r*r; printf("Sphere (%2d) Radius = %4.1f Area = %7.3f Volume = %7.3f\n",k+1,r, a,v); tr=tr+r; ta=ta+a; tv=tv+v; } r_av=tr/21; a_av=ta/21; v_av=tv/21; printf("\n"); printf("Total Area = %7.3f Total Volume = %7.3f\n\n",ta,tv); printf("Average Radius = %7.3f Average Area = %7.3f Average Volume = %7.3f\n ",r_av,a_av,v_av); printf("\n\n"); } Sphere ( 1) Radius = 2.0 Area = 50.265 Volume = 33.510 Sphere ( 2) Radius = 2.1 Area = 55.418 Volume = 38.792 Sphere ( 3) Radius = 2.2 Area = 60.821 Volume = 44.602 Sphere ( 4) Radius = 2.3 Area = 66.476 Volume = 50.965 Sphere ( 5) Radius = 2.4 Area = 72.382 Volume = 57.906 Sphere ( 6)...
View
Full Document
 Fall '07
 Lubarda
 The Land, Void type, printf, Radius Radius Radius Radius Radius Radius Radius Radius Radius Radius, Radius Radius Radius Radius Radius Radius Radius Radius Radius Radius Radius, Sphere Sphere Sphere Sphere Sphere Sphere Sphere Sphere Sphere Sphere, Sphere Sphere Sphere Sphere Sphere Sphere Sphere Sphere Sphere Sphere Sphere

Click to edit the document details