From 2885c38b63b921066bf2fd12a17f44873dc4b786 Mon Sep 17 00:00:00 2001 From: Rumeet Date: Tue, 12 Jul 2016 12:10:32 -0400 Subject: [PATCH 1/5] Rumeet Goradia - Sorting Program --- sort.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 sort.c diff --git a/sort.c b/sort.c new file mode 100644 index 0000000..8d7f2c0 --- /dev/null +++ b/sort.c @@ -0,0 +1,63 @@ +#include +#include +#include + +int main () +{ + int n; + printf("Please input the number of integers in the array.\n"); + scanf("%d", &n); + int *myArray = (int*) malloc(n*sizeof(int)); + int i; + srand(time(NULL)); + for (i=0; imyArray[k]) + { + greatness++; + } + } + ascArray[greatness]=myArray[j]; + }int *desArray = (int*) malloc(n*sizeof(int)); + int f, g, lessness; + for (f=0; f Date: Tue, 12 Jul 2016 15:18:32 -0400 Subject: [PATCH 2/5] Rumeet Goradia - Sorter Program (edited) --- sort.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sort.c b/sort.c index 8d7f2c0..4900bb8 100644 --- a/sort.c +++ b/sort.c @@ -1,3 +1,4 @@ +/*Rumeet Goradia - Sorter Program*/ #include #include #include @@ -59,5 +60,8 @@ int main () { printf("%d\n", desArray[b]); } + free(myArray); + free(ascArray); + free(desArray); return 0; } From 0d891e40752959d2c09e8d72f40c01a8249c1c0f Mon Sep 17 00:00:00 2001 From: Rumeet Date: Wed, 13 Jul 2016 00:31:15 -0400 Subject: [PATCH 3/5] Rumeet Goradia - Assignment 8 Part 2 --- assignment8.txt | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 assignment8.txt diff --git a/assignment8.txt b/assignment8.txt new file mode 100644 index 0000000..b52edf9 --- /dev/null +++ b/assignment8.txt @@ -0,0 +1,6 @@ +Rumeet Goradia +1. The output of the program is ABCabc123. In all honesty, I don't know where the capital B and the capital C come from. I can understand that the "abc" is from the output on line 31, but I don't see where the 123 is also put into p. +2. If the program was run with "valgrind" instead of "abc 123", I think the program wouldn't run all the way since there would only be two arguments instead of three and the first "if" statement would be activated. But if "valgrind" is stored in the allocated memory of the program regardless, 8 bytes (1 for each char element) would be lost. +3. Line 28 is redundant because q is never really used. Because of this, I think the following two lines are also not needed because they don't serve a purpose in printing the strings or anything. I also think that line 14 should be modified since c is given memory for two bytes but at any given time only the first one is being used. +4. line 14 --> char *c; +line 28 --> free(p); From 9317c3d7cf6931f1ee32c17a6e005c72c28b3fa6 Mon Sep 17 00:00:00 2001 From: Rumeet Date: Wed, 13 Jul 2016 00:31:44 -0400 Subject: [PATCH 4/5] Rumeet Goradia - Floats for Average + Standard Deviation Program --- floats.txt | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 floats.txt diff --git a/floats.txt b/floats.txt new file mode 100644 index 0000000..20632fe --- /dev/null +++ b/floats.txt @@ -0,0 +1,26 @@ +25 +348.241 +414.193 +589.902 +675.498 +245.269 +497.712 +198.687 +392.412 +895.629 +719.312 +423.874 +148.209 +986.587 +393.283 +691.848 +1004.289 +286.294 +526.839 +888.574 +483.236 +192.382 +567.129 +943.234 +112.148 +999.999 From f0602cd12c4552527fce0d5cc61d344d4b6808e2 Mon Sep 17 00:00:00 2001 From: Rumeet Date: Wed, 13 Jul 2016 00:32:05 -0400 Subject: [PATCH 5/5] Rumeet Goradia - Average & Standard Deviation --- stats.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 stats.c diff --git a/stats.c b/stats.c new file mode 100644 index 0000000..4b7a229 --- /dev/null +++ b/stats.c @@ -0,0 +1,35 @@ +#include +#include +int main() +{ + FILE *a = fopen("floats.txt", "r"); + int num; + fscanf(a, "%d", &num); + float x[num]; + int i; + for (i=0; i