HW1
HW 1
8/30/2018
1. Write a program to convert meters to miles.
8/30/2018
1. Write a program to convert meters to miles.
/* this program convert meters to miles.*/
#include <stdio.h>
#include <math.h>
int main(void) {
/* input variables */
#define M 0.000621371
float x= 5 , miles;
/*compute miles*/
miles = x*M;
/* print miles */
printf("=""%f", miles);
/* Exit program */
return 0;
}
2. Write a program to convert degrees Celsius to degrees Rankin.
3. Write a program to compute the area of an ellipse with semiaxesa and b
4. Write a program to compute the area of a sector of a circle when d is the angle in degrees between the radii.
/* this program convert degree celcius to rankin.*/
#include <stdio.h>
#include <math.h>
int main(void) {
/* input variables */
#define R 273.15
float C= 35 , T;
/*compute F*/
T = (C+R)*1.8;
/* print T */
printf("degree C is""% f degree T",T);
/* Exit program */
return 0;}
/* this program solve for ellipse erea.*/
#include <stdio.h>
#include <math.h>
int main(void) {
/* input variables */
#define pi 3.14
float semiaxes= 2, b=4, area;
/*compute area*/
area = pi*b*semiaxes;
/* print area */
printf("ellipse erea is ""%f",area);
/* Exit program */
return 0;
}
/* this program solve for erea sector.*/
#include <stdio.h>
#include <math.h>
int main(void) {
/* input variables */
#define pi 3.14
/* theda rad */
float theda= pi/4, r=4, area;
/*compute area*/
area = (theda*r*r)/2;
/* print area */
printf("sector erea is ""%f",area);
/* Exit program */
return 0;
}
Comments
Post a Comment