MAE9 HW2

MAE9 HW2 - /* My Homework 2 */ #include <stdio.h>...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
(e) Compute the area (A) and the volume (V) of a sphere with radius R=1.0, R=1.2, R=1.4, . .. , R=4.0 . Define PI by using #define and use a for-loop to repeat calculations for different values of R. (Use PI=3.14159265359 and recall the elementary formulas A=4.0*PI*R*R and V=4.0*PI*R*R*R/3.0). For each sphere, print in one line Radius = "number" Area = "number" Volume = "number" Use the output specifier %4.1f for R, and %7.3f for A and V. .......................................................................
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: /* My Homework 2 */ #include <stdio.h> #define PI 3.14159265359 int main (void) { printf("\n"); printf ("Part I:\n\n"); int a=52, b=7, c; c=a%b; printf("%d modulo %d = %d \n",a,b,c); printf("\n"); printf("Part II:\n\n"); int k; double R,V,A; for(k=0; k<=15; k++) { R = k/5.0 + 1.0; A = 4.0*PI*R*R; V = 4.0/3.0*PI*R*R*R; printf ("Radius = %4.1f Area = %7.3f Volume = %7.3f \n",R,A,V); } }...
View Full Document

This note was uploaded on 05/22/2008 for the course MAE 9 taught by Professor Lubarda during the Fall '07 term at UCSD.

Ask a homework question - tutors are online