diff options
| author | Alexander Pickering <alexandermpickering@gmail.com> | 2017-02-06 11:26:44 -0500 |
|---|---|---|
| committer | Alexander Pickering <alexandermpickering@gmail.com> | 2017-02-06 11:26:44 -0500 |
| commit | 97a693d996c79fb2a008b19750d8bb45512e01a2 (patch) | |
| tree | 6df17bfe7de7c59f7b1083828d71a91e61fae9fa /cpp | |
| download | engr0016-master.tar.gz engr0016-master.tar.bz2 engr0016-master.zip | |
Diffstat (limited to 'cpp')
| -rw-r--r-- | cpp/functions.c | 3 | ||||
| -rw-r--r-- | cpp/stuff1.c | 162 | ||||
| -rw-r--r-- | cpp/whilelooppractice.c | 13 |
3 files changed, 178 insertions, 0 deletions
diff --git a/cpp/functions.c b/cpp/functions.c new file mode 100644 index 0000000..1cb8d01 --- /dev/null +++ b/cpp/functions.c @@ -0,0 +1,3 @@ +#include <stdio.h> +int main () +{} diff --git a/cpp/stuff1.c b/cpp/stuff1.c new file mode 100644 index 0000000..8f0269c --- /dev/null +++ b/cpp/stuff1.c @@ -0,0 +1,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; +} diff --git a/cpp/whilelooppractice.c b/cpp/whilelooppractice.c new file mode 100644 index 0000000..f1d1c9b --- /dev/null +++ b/cpp/whilelooppractice.c @@ -0,0 +1,13 @@ +#include <stdio.h> +int main() +{printf("Hello World!\n"); +int ear=40; +while (ear>20) +{ + printf("Elephants are pretty cool!\n"); + printf("%i",ear); + ear=ear-1; +} +return 0; +} + |
