diff --git a/assignment8.txt b/assignment8.txt new file mode 100644 index 0000000..bb8d331 --- /dev/null +++ b/assignment8.txt @@ -0,0 +1,7 @@ +Lloyd Page +1. CAN CRASH(potential for infinite while loop) +char value at 129+130+131+"abc" +2. 7 +3. 29(infinite while loop) +4. 29: while((*q++==*b++)!=0) ; + 32: free(p); diff --git a/filestanddev.c b/filestanddev.c new file mode 100644 index 0000000..4eb20d8 --- /dev/null +++ b/filestanddev.c @@ -0,0 +1,45 @@ +/*Lloyd Page*/ +/*reads floats from float1.txt, calculates meand and stand dev of all read in values*/ +#include +#include +#include +float avg(float[],int); +float stddev(float[],float,int); +int main() +{ + int x; + char handler[100]; + FILE *f=fopen("float1.txt","r"); + fgets(handler,sizeof(handler),f); + x=atoi(handler); + float num[x]; + for(int i=0;i +#include +#include +#include +void insertUp(int*,int); +void insertDn(int*,int); +int main() +{ + srand(time(NULL)); + int size; + while(1) + { + int N=3; + char *line=malloc(N); + printf("Enter the size of the array\n"); + fgets(line,N,stdin); + size_t last=strlen(line); + while(line[last-1]!='\n') + { + N*=2; + line=realloc(line,N); + fgets(line+last,N/2,stdin); + last=strlen(line); + } + if(sscanf(line,"%d",&size)) + break; + } + int *a=(int*)malloc(size*4); + for(int i=0;i-1;i--) + { + for(int j=i;j>-1;j--) + { + if(*(n+i)<*(n+j)) + { + int temp=*(n+i); + *(n+i)=*(n+j); + *(n+j)=temp; + } + } + } +}