Homework Number 1

/* Author: V. Karthik Duggirala ENGR 6 /*
/* This program will convert meters into miles */

#include <stdio.h>
#include <math.h>

int main(void) {
 float meters=999, miles;
 /*attempted user input, error: miles always result in 0 */
 /*printf("Input number of meters \n");
 scanf("%s", meters); */
 miles = meters/1609.34;
 printf("The number of meters you have inputed is %.5f miles", miles);
 return 0;
}
---------------------------------------------------------------------------------------------------------------------
/* Author: Karthik Duggirala ENGR 6 */
/* This program will convert Degrees Celsius to Rankine */

#include <stdio.h>
#include <math.h>

int main(void) {
float celsius = 999, kelvin, rankine;
/*First we convert from celsius to kelvin */
kelvin = (celsius+273.15);
/*Then we convert from Kelvin to Rankine */
rankine = kelvin*9/5;
printf("That is %.4f Rankine.", rankine);
return 0;
}
------------------------------------------------------------------------------------------------------------------------
/* Author: Karthik Duggirala ENGR 6 */
/* This program calculates the area of a sector of a circle given r, the radius, and d, the angle in degrees between the two radii */

#include <stdio.h>
#include <math.h>
/*define pi */
#define pi 3.14

int main(void) {
/* declare variables */
float d = 360, r =10, area, radians;
/* convert degrees to radians */
radians = pi/180 *d;
/* Use formula to get area of sector */
area = r*r*radians/2;
printf("The area of the sector is %.2f units squared", area);
return 0;
}
----------------------------------------------------------------------------------------------------------------------
/*Author: Karthik Duggirala ENGR 6 */
/* This program calculates the area of an ellipse based on the given semiaxes a and b */

#include <stdio.h>
#include <math.h>
/*Define what pi is */
#define pi 3.14159265

int main(void) {
/* declare and define floats */
float semiaxis_a = 9, semiaxis_b = 13, area;
/* calculate area */
area = semiaxis_a*semiaxis_b*pi;
/*print the answer */
printf("The area of the eclipse is %.3f units squared", area);
return 0;
}

Comments

Popular posts from this blog

Seismic Code

Strings

BMP180 Code + Library to SD card