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); 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 diff --git a/sort.c b/sort.c new file mode 100644 index 0000000..4900bb8 --- /dev/null +++ b/sort.c @@ -0,0 +1,67 @@ +/*Rumeet Goradia - Sorter Program*/ +#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 +#include +int main() +{ + FILE *a = fopen("floats.txt", "r"); + int num; + fscanf(a, "%d", &num); + float x[num]; + int i; + for (i=0; i