diff --git a/array b/array new file mode 100755 index 0000000..72c94ff Binary files /dev/null and b/array differ diff --git a/array.c b/array.c new file mode 100644 index 0000000..5ac6fdc --- /dev/null +++ b/array.c @@ -0,0 +1,39 @@ +//Emma +//returning an arry with sum + + +#include +#include + + +int main(){ + + int array[8]={1, 2, 5, 7, 7, 8, 10, 4}; + + int out[8]; + + int i; + int sum =0; + for(i=0; i<8;i++){ + + sum = sum + array[i]; + + } + + int j; + int print; + for(j=0; j<8;j++){ + + out[j] = sum - array[j]; + + + + } + + for(print=0; print<8; print++){ + printf("%d\n", out[print]); + } + + return 0; + +} diff --git a/assignment4.txt b/assignment4.txt new file mode 100644 index 0000000..55d3429 --- /dev/null +++ b/assignment4.txt @@ -0,0 +1,11 @@ +Emma Ladouceur + +1. A character array in c separates each letter into its own section. s[10] = {"h", "e", etc..} +whereas if you wanted it as a string you could simply put it as s[10] = {"hello"}. The cmputer still sees each space as 0-10, but it will recognize each section. +C doesn't have its own thing for a string, so in a sense a string is just a character array + +2. Arrays in c are kind of confusing because you cannot mix different values. Its either char or int which makes it extremely hard to put things together. In ruby you can have numbers and strings and chars. Its also really really challenging, maybe impossible to create an empty array. Ispent about 4 hours this weekend trying to figure that out and even purchased a text book. If you want to set. The arrays are static and the size cannot change after initialization. I can think of no advantages. + +3. When an array is in an an expression it won't generate the address the first element of the array. + +4. If theyre the exact same 0 will be returned. diff --git a/count b/count new file mode 100755 index 0000000..87af0ed Binary files /dev/null and b/count differ diff --git a/count.c b/count.c new file mode 100644 index 0000000..38d82ce --- /dev/null +++ b/count.c @@ -0,0 +1,118 @@ +//Emma Ladouceur +//counts the occurence of letters in a string +//I feel like I'm close in this one but it was printing before and now it won't. I tried debugging and it compiles, but it doesn't go further than that. I'll finish all of these things after class, but I think i need some ideas, so maybe we'll go over it. Otherwise I'll just work on it more tomorrow, but I've spent about 4 hours on these last two. +// I do know that it's not recognizing the increases when you type in strings or the switch statement because I added an a++ at the bottom and it prints a:100, but i don't know how to fix it. +#include + + +int main(){ + +int a=0, b=0, c=0, d=0, e=0,f=0,g=0,h=0,i=0,j=0,k=0,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z; + +int print; + +int ii; +int occur=100; +char string[occur]; + +printf("Enter a string of characters"); +scanf("%c", &string[occur]); + + for(ii=0; ii0){ + printf("a : %d\n", a); + } + if(b>0){ + printf("b : %d\n", b); + } + if(c>0){ + printf("c : %d\n", c); + } + + if(d>0){ + printf("c : %d\n", d); + } + + if(e>0){ + + printf("e : %d\n", e); + } + + if(f>0){ + printf("f : %d\n", f); + } + + if(g>0){ + printf("g : %d\n",g); + } + + if(h>0){ + printf("h : %d\n", h); + + } + + if(i>0){ + printf("i : %d\n", i); + } + + if(j>0){ + printf("j : %d\n", j); + } + + + + return 0; + +} + + diff --git a/double b/double new file mode 100755 index 0000000..6ecf076 Binary files /dev/null and b/double differ diff --git a/double.c b/double.c new file mode 100644 index 0000000..6597eba --- /dev/null +++ b/double.c @@ -0,0 +1,37 @@ +//Emma Ladouceur +//This does not work! +//I've tried so many things but cannot figure it out. I honestly don't know what else to try so if we could go over after class I would really appreciate it +//It compiles and prints 6 things, but ideally it would 1 only print 3 and 2 it would be the correct 3 things +//on the bright side, nothing is negative anymore and it does compile +#include + + +int main(){ + int number, i, k, h, j; + int arr1[6] = {1,1,2,2,3,3}; + int arr2[6]; + + arr1[6] = arr2[6]; + for(i=0; i<6; i++){ + for(j=0;j<6;j++){ + if(arr1[i]==arr1[j]){ + break; + } + + if(i==j){ + arr1[i]=arr1[j]; + i--; + } + } + + } + + + + for(k=0; k<6; k++){ + printf("%d\n", arr2[k]); + } + + +return 0; +} diff --git a/hangman b/hangman new file mode 100755 index 0000000..0571cb9 Binary files /dev/null and b/hangman differ diff --git a/hangman.c b/hangman.c new file mode 100644 index 0000000..8babf32 --- /dev/null +++ b/hangman.c @@ -0,0 +1,37 @@ +//Emma Ladouceur +//This is incomplete but in the works, I took so long on the other two that by the time I got to this I had very little time. SO sorry! + +#include + +int main(){ + + + int i, j,k; + + printf("This is Hangman\n Enter a letter to guess."); + + char string[3] = "NYC"; + + char guess; + + scanf("%c", &guess); + + printf("You have 4 guesses"); + + for(i=0; i<4; i++){ + if(guess =='N' || guess=='Y' || guess=='C'){ + + printf("youre right."); + + } + + else{ + break; + } + + i++; + } + + + +}