summaryrefslogtreecommitdiff
path: root/cpp/stuff1.c
blob: 8f0269c9feea1943adc296679942d90af15e44a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define A 4
#define B 2

int main()
{
    char doagain = 'Y';
    while (doagain=='Y'|| doagain == 'y')
    {
        float a[A];
        
        float w;
        float x;
        float y;
        float z;
        
        float fw;
        float fx;
        float fy;
        float fz;

        float b[2][B];
        
        float m;
        float n;
        float o;
        float p;

        float im;
        float in;
        float io;
        float ip;
             
        int any;
        printf("press 1 to convert F to C, \n press 2 to convert Inchs to Centimeters, \nor press 3 to convert Degrees to Radians.");
        scanf("%i",&any);
        
        if (any < 1 || any > 3)
        {
                printf("error! try again! \n");
        }
        
        if (any == 1)
        {
        /*Changes a given number of celsius to farenhight*/
            printf("Enter first celsius value");
            scanf("%f",&w);

            printf("Enter second celsius value");
            scanf("%f",&x);

            printf("Enter third celsius value");
            scanf("%f",&y);

            printf("Enter fourth celsius value");
            scanf("%f",&z);

            fw = ((9.0 / 5.0)*(w + 32));
            fx = ((9.0 / 5.0)*(x + 32));
            fy = ((9.0 / 5.0)*(y + 32));
            fz = ((9.0 / 5.0)*(z + 32));

            a[0]=fw;
            a[1]=fx;
            a[2]=fy;
            a[3]=fz;

            printf("\n\n Celsius to Fahrenheit Array \n a[0]= %.2f, a[1]= %.2f, a[2]%.2f,a[3] %.2f\n\n",a[0],a[1],a[2],a[3]);
        }
        
        if (any == 2)
        {
            /*This (probably) turns an entered number of centimeters to inches*/

            printf("Enter first value for centimeters");
            scanf("%f",&m);

            printf("Enter second value for centimeters");
            scanf("%f",&n);

            printf("Enter third value for centimeters");
            scanf("%f",&o);

            printf("Enter fourth value for centimeters");
            scanf("%f",&p);

            im = m*2.54;
            in = n*2.54;
            io = o*2.54;
            ip = p*2.54;

            b[0][0]=im;
            b[0][1]=in;
            b[1][0]=io;
            b[1][1]=ip;

            printf("\n Cm to Inches Array \nb[0][0]=%.2f,b[0][1]=%.2f\n,b[1][0]=%.2f,b[1][1]=%.2f\n\n",b[0][0],b[0][1],b[1][0],b[1][1]);
        }
        
        if (any == 3)
        {
            /*Radiant*/
            float h;
            float i;
            float j;
            float k;
            
            printf("Enter the first value in degrees");
            scanf("%f",&h);
            
            printf("Enter the second value in degrees");
            scanf("%f",&i);
            
            printf("Enter the thind value in degrees");
            scanf("%f",&j);
            
            printf("Enter the fourth value in degrees");
            scanf("%f",&k);
            float degree[4];
                    
            degree[0] = h;
            degree[1] = i;
            degree[2] = j;
            degree[3] = k;
                    
            float rad[4];
            
            rad[0] = h*(0.0175);
            rad[1] = i*(0.0175);
            rad[2] = j*(0.0175);
            rad[3] = k*(0.0175);
            
            float matrix[6][4];
            int index = 0;
            while (index < 4)
            {
                matrix[0][index] = sin(rad[index]); 
                matrix[1][index] = cos(rad[index]);     
                matrix[2][index] = tan(rad[index]);
                matrix[3][index] = asin(matrix[0][index]); 
                matrix[4][index] = acos(matrix[1][index]);     
                matrix[5][index] = atan(matrix[2][index]);
                index = index+1;
            }
        //Matrix has functions stored in columns
            int row = 0;
            int col = 0;
        ////////   6      6    3   3   3   4    4    4
            printf("\ndegree radian sin  cos  tan  asin  acos  atan\n");
            while(col < 4)
            {
                printf("%.4f %.4f %.2f %.2f %.2f %.3f %.3f %.3f\n",degree[col],rad[col],matrix[0][col],matrix[1][col],matrix[2][col],matrix[3][col],matrix[4][col],matrix[5][col]);
                col++;
            }
        }   
    printf("type Y to doagain or N to quit");
    scanf(" %c",&doagain);
    }
    return 0;
}