Wednesday, March 1, 2017

homework 3/1/17

1.
/*meters to miles conversion*/
#include <stdio.h>
#include <math.h>
int main(void)
{
    /* the variables meters and miles */
    double m=10000, mi;
    /* formula */
    mi=.000621371192*m;
    /*print distance in miles */
    printf("The distance from meters to miles is""%5.2f \n", mi);
    /* exit */
    return 0;
}
/*end*/

2.
/*Celsius to Rankine conversion*/
#include <stdio.h>
#include <math.h>
int main(void)
{
    /* the variables Celsius and Rankine */
    double C=100, R;
    /* formula */
    R=1.8*(273.15+C);
    /*print temp in rankine */
    printf("The temperature in rankine is" "%5.2f \n",R);
    /* exit */
    return 0;
}
/*end*/

3.
/*calculate ellipse area*/
#include <stdio.h>
#include <math.h>
int main(void)
{
    /* the variables a,b,A,pi */
    double A, pi=3.14, a=1,b=2;
    /* formula */
    A=pi*a*b;
    /*print area of ellipse */
    printf("The area of ellipse is" "%5.2f \n",A);
    /* exit */
    return 0;
}
/*end*/

4.
/*calculate sector of a circle area*/
#include <stdio.h>
#include <math.h>
int main(void)
{
    /* the variables A,r,theta,pi */
    double A, pi=3.14, theta=180,r=5;
    /* formula */
    A = pi*(r*r)*(theta/360);
    /*print area of circle */
    printf("The area of sector of circle is" "%5.2f \n",A);
    /* exit */
    return 0;
}
/*end*/


calculate values

1. int a=27, b=6, c;

c= b%a;

c=6;


2.int a=27, b=6;

float c;

c=a/(float)b;

27/6.0=4.5;

3. int a;

float =b;

c=18.6;

a=c/b;

18.6/6=3.1=3;

4.int b=6;

float =a ;

c =18.6;

a=(int)c/b;

18/6=3.;

Identify valid identifiers

1. density y
2. area y
3. Time y
4. xsum y
5. x_sum y
6. tax-rate n tax_rate
7. perimeter y
8. sec^2 n secsqrd
9. degrees_C y
10. break n skip
11. #123 n 123
12. x&y y
13. count y
14. void n null
15. f(x) y
16. f2 y
17. Final_Value y
18. w1.1 y
19. reference1 y
20. reference_1 y
21. m/s y