From a5a373997103dd2eb0084de1c61e7d8f23310c02 Mon Sep 17 00:00:00 2001 From: AvaEN Date: Wed, 6 Jul 2016 19:51:59 -0400 Subject: [PATCH 1/6] Assignment 6 --- assignment6.txt | 8 ++++ bank | Bin 0 -> 8824 bytes banking.c | 52 +++++++++++++++++++++ cat | 0 complex | Bin 0 -> 8768 bytes complex.c | 88 ++++++++++++++++++++++++++++++++++++ less | 0 structure | Bin 0 -> 21072 bytes student_structure.c | 107 ++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 255 insertions(+) create mode 100644 assignment6.txt create mode 100755 bank create mode 100644 banking.c create mode 100644 cat create mode 100755 complex create mode 100644 complex.c create mode 100644 less create mode 100755 structure create mode 100644 student_structure.c diff --git a/assignment6.txt b/assignment6.txt new file mode 100644 index 0000000..9526e7c --- /dev/null +++ b/assignment6.txt @@ -0,0 +1,8 @@ +Ava N. +July 6, 2016 + +Assignment 6: (still working on questions) + +1. The function will print: +2. Structures are collections of related variables under a single name. Enumerates define a set of named integer canstants starting from 0. +3. Passing an array directly to a function as an argument. Passing a structure containing an array causes the array to be copied to the function's parameter. diff --git a/bank b/bank new file mode 100755 index 0000000000000000000000000000000000000000..ac520a55144f0123f9679859be500817b21b5b3e GIT binary patch literal 8824 zcmeHMU2GiH6~4P`I~ymgHvyWEpk~^}l@rMuJ8^;oDw(yt$rw35ICdHYW<1^>?~>ge zYiBmG=|hbS5vw%R6|~Ju)kqa8NR?>Sm+;WWsZksdY7K%HT2(1EtsM$Af00{Cw&&cr zXLt5`t){4bNawx&L?Wz5DG*&wj7R!zg&!y$rRBo>u4@7S|w1DOMD%LoBtKnN#z}r{A_pN~654Zx49B?>R%a=j> zMX|Z|FkMesW_0gf-HIC71RKfQ7GRcbL{I3^J41JsVr`|^&d_csl^1?K{>C2hKpfkf#>IwI>K4QY1$G

C_;K!kU>a+c2$BA4Oz+nod!IYFbi)S@w8ElxX?~yPxvaf* z!@j-bZ4G&A*un;;o&3kYu@1`5^6UD6IG=@r4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dAx1o_RHtv*b08W zzXJaJ3iuVkF<*K7zX^D?dd&g8&U*(tBF&2r5C>1RKGaZ~Km%fX;`IauzQ+amCOkp5 zi497AehYqh`-^$89Z3*^;0NvH_PJB|$9oS9e2)$CD}XBqNMSd(mq1Vt1CI5Q{Xe*Z zpL*`6$~qj)*_NG8BtlWRa=WjySMTXQ+NbL*7SF|pQ2^ksrs0^1*LX2gA5NP? zMp}>AX3o-${3wf>nUQqdj>kfG?QY*)-AGTQvMJrj<%}^sp0#shERi!ZaXpsLWX6Ev z(sZ!2D@=!s?1@x%m=|$>Z}?zDj~wcPGCBpOcm*xS^sWaEg%5Ujf|V`#p)BD05JrT@--%CcVJg)#RgwC?~1!q=rzmKlSVcM z1=70@gH*yTB%$?Y$ec#EK9g??qTmcsrQPJ(3v(Yiw^_$4R5(1cL5!0PrZZ9 zLW8KHQCP?t%h<*cNIU1qB*oy$Bc2;!p{!}gL*b6@X4@DR+Hf`>8p@~Ojy@G*A=HwF zm1LpVSQh*_(#|<4C*wIQWo9cB9nx~~w1ET>8%f(N#48?xXlU33)sBzC8^7i8BT+DeY>Z4Q3S}^DbPovjdgy_h~OEC__Y7MAb=@hSO*g8PJGy5@o)^@c!nZA z?UP5v!D^gam0xoEJq$^B1|mM~rAL{{mbbyTqq+ z8vRdB|A*7~ru=CfoRjjW{|}e2QV_`A(aJjEe}@Ej`Ag?Mk%2};A&EzFN#fJ~SQC6I zC%GXW={F#P7}cNlmB$59wwHz@^8tWZ3po^$_{|bde3I)Ro$_{@J}WNX){>z}lvJKK l%^f%YNm2giM8|y@5_iBu^`UhU=V!J2Tf{|KUUDwy|8HQXz6$^V literal 0 HcmV?d00001 diff --git a/banking.c b/banking.c new file mode 100644 index 0000000..14e7d60 --- /dev/null +++ b/banking.c @@ -0,0 +1,52 @@ +/*Ava N.*/ +//This program uses structures to represent a bank account. The accounts have an account number, name, and balance. I created functions to deposit or withdraw money from the balance. Write a driver that creates 2 accounts, adds money to each, then withdraws money from each. Print details of the account between each transaction. + +#include +#include +#include + +typedef struct{ + char name[2]; + int balance; + float age; +} account; + +int main(){ + account a1, a2; + strcpy(a1.name, "Business"); + strcpy(a2.name, "Home"); + + int i; + + a1.balance = 0; + a2.balance = 0; + +//Deposit part: + printf("How much money do you want to deposit into the %s account? Amount of money in account: %d\n", a1.name, a1.balance); + scanf("%d", &i); + a1.balance = a1.balance + i; + + printf("How much money do you want to deposit into the %s account? Amount of money in account: %d\n", a2.name, a2.balance); + scanf("%d", &i); + a2.balance = a2.balance + i; + + +//Withdrawal part: + printf("How much money do you want to withdraw into the %s account? Amount of money in account: %d\n", a1.name, a1.balance); + scanf("%d", &i); + a1.balance = a1.balance - i; + + printf("How much money do you want to withdraw from the %s account? Amount of money in account: %d\n", a2.name, a2.balance); + scanf("%d", &i); + a2.balance = a2.balance - i; + + + printf("\n"); + + printf("Your Receipt: \n"); + printf("You have %d amount of money in your %s account \n", a1.balance, a1.name); + printf("You have %d dollars in your %s\t account \n", a2.balance, a2.name); + + return 0; + +} diff --git a/cat b/cat new file mode 100644 index 0000000..e69de29 diff --git a/complex b/complex new file mode 100755 index 0000000000000000000000000000000000000000..ea0a2f89f1f8ab16f58cb33d38d87a52346e9250 GIT binary patch literal 8768 zcmeHMeQaA-6~DIg)iiV5(ym=Pt&h>LbZgwCP1Cd+^f`&smo4c+n(RX(dwH>)5E^mU(K7ykOxj?KA%(G_WZg%mZ6#xC%{lko z^ZfkmXcH3uaijOnJ-_pD&$%DZ_uhOp*wf{9xfm5U`#eLguUzJk`DSdoj!lpp4X&w%hZ;Ff_yUPi(? z`8!Wh7fau3Mi}e!YdH&4<`tqXCd`PE-50Clvcdd#m-!vdE99VA;;7KGNE< zGa7D;>ao;R<5XK~V{3~)8Taqvd82>SJ$Pu4w?zFY0f#YffCuLQ%D-Iqq}^FT?KDi1>d_0-VL|}kF(%#m1>tkKZUScTA8Zq z$#`hrJ~bKAVxw#_Wh4Ph8d~Ux8X7;Mj%s?8O(yi1F$y@^p)g^n6P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Cy3Mf_hN_`3>A+4`Q-ev$sKMCS@}jk@;o8DJ{mfzJdlw6CQ9+eiW@Lf=K=o1tR2 zr~RiP9Bv~;L7n!UfM0^WKed0_EpyG&0-*TuJdcIW879ZrA*kS4hwN!TJ1c-kg<=Iz z%$@9E$HdDW@W!(c*$;bUjt`3i(iG?NFK7SV3nDzrkUi~>UljIUVM_6n9?>Hp$FmXf zw2xjC_Oh^d#xG!o`yT95vZwuagXn0=liGLYf4{JA7Y^xsCkuPZAMMeX)BZuguum{P zEVO^074~$_HKk^(R7aYI$8Jyi`~_h@j7qjb|Gy#n5XkKIve;kBB4LV`TsZk3IPB?n zyHD8ni#W)h+9m!GhdrGy&WHmror6i=;g0=8*wgsY{^N0BD3L%oaK`_0hduqDbRHK4 zlopd%Z)f{+Ai@5lX6Rf~B`!GLvnHpd^zo~ti2d5qF)Bg!qFexacZ*qB_ z@V7x=kDt+gQZyiwp`c_(bj4v$`(RnvQ=H_6?1;Yt6~rii+CTOQL#IB*YA+rD5Noo7 zP$&CF2Tt}x*MXecwyREx3$z+i6ha4EFn8_t(<1&;V&JX=;ZArcAN-bK!DUveeV@4S P8m5K8war{bm6QJfwKOru literal 0 HcmV?d00001 diff --git a/complex.c b/complex.c new file mode 100644 index 0000000..9dce75f --- /dev/null +++ b/complex.c @@ -0,0 +1,88 @@ +/*Ava N.*/ +//This program implements complex numbers as a structure and allows a user to perform calculations with them. The structure contains real and imaginary portions of a complex number. The functions add, subtract, multiply, divide and display complex numbers. I have allowed the user to select what functions they want to use (much like my calculator.c programs from last week) and enter the complex numbers they want to perform calculations with. + +#include +#include + +typedef struct { + int real; //real + int imag; //imaginary +} complx; + +int main(){ + complx f; //first number + complx s; //second number + complx a; //answer + complx o; //operation + + printf("Choose one of the following: +, -, *, /, or %%: \n"); + scanf("%d\n", &o.real); + + printf("Pick a real number: \n"); + scanf("%d\n", &f.real); + + printf("Pick another real number: \n"); + scanf("%d\n", &s.real); + + printf("Choose one of the following: +, -, *, /, or %%: \n"); + scanf("%d\n", &o.imag); + + printf("Pick an imaginary number: \n"); + scanf("%d\n", &f.imag); + + printf("Pick another imaginary number: \n"); + scanf("%d\n", &s.imag); + + switch(o.real){ + case '+': + a.real=f.real+s.real; + printf("The addition is: %d\n", a.real); + break; + case '-': + a.real=f.real-s.real; + printf("The subtraction is: %d\n", a.real); + break; + case '/': + a.real=f.real/s.real; + printf("The division is: %d\n", a.real); + break; + case '*': + a.real=f.real*s.real; + printf("The multiplication is: %d\n", a.real); + break; + case '%': + a.real=(int)f.real%(int)s.real; + printf("The percentage is: %d\n", a.real); + break; + default: + printf("Your response was invalid. Please try again."); + } + switch(o.imag){ + case '+': + a.imag=f.imag+s.imag; + printf("The addition is: %d\n", a.imag); + break; + case '-': + a.imag=f.imag-s.imag; + printf("The subtraction is: %d\n", a.imag); + break; + case '/': + a.imag=f.imag/s.imag; + printf("The division is:%d \n", a.imag); + break; + case '*': + a.imag=f.imag*s.imag; + printf("The multiplication is: %d\n", a.imag); + break; + case '%': + a.imag=(int)f.imag%(int)s.imag; + printf("The percentage is: %d\n", a.imag); + break; + default: + printf("Your response was invalid. Please try again."); + } + printf("%d \n", a.imag); + printf("%d \n", a.real); + + return 0; +} diff --git a/less b/less new file mode 100644 index 0000000..e69de29 diff --git a/structure b/structure new file mode 100755 index 0000000000000000000000000000000000000000..6039135e9a5d82a37cd4e24387bec707c4d06b28 GIT binary patch literal 21072 zcmeHPeQ;FQb-&UI5H^+;Y&Y`9gpCW0><()I0xNc7o<0_yhyVq&F13wUEA0x&)>rq# z7M^A*SFDGfja*F|b@Wdl{TMRSY1MiLMDZZ}FBxYSe0FsrBl9wGx^YI4sT~Dx9J7x@bd7wVemF1V>G=C~Ar=W(>Vw)Tlv{X(3Un zZy{Nl725QOh=wZVV+Hw9TfL972-?bwp{5;{ZjbRJk^CyPU#0dlbV@hOP!k`;Mn{V- zucg?6M6yLhHSq5OC0k0(mlF}uSn!MU@zpn2_{W7QHGgOP} z;qI=s?bQ!=M>chL^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w0 z4lSX89g@=QhW#qEt7%_dZBuC9&YcGWEuog$x~2ftz`L5X$CDh2+4RJ+%x)&Mhe@ch zWlw0K=UVpEQ@^!@+q$DF6pe%vVU&}FNz7&+8F$csh0!{ng3{_ceGbC7!q}kue+-I1w$u>9rDuh)yupDqQc+>3Tr@i#bkTr14RI4fa8vAgeE zXulv&j=#afHYt(XggC$M{-by1>E6cFZ*cQ#+TYwan)VwzL!W~`-76W{;OlYiU!`ky zx8F2~@DTN>@i#bpM*9OXax(S1<3EaA@~;y!2$pc9L~7+8u9BD24m+ukj|1z*}N$oQN4r;5j+ zL~`4^<7enR^ttsLd|YFRgK4LBU(}xK$e^-J{~26qTjF8r5lQMY zJW&rSr}|x|3GgZ9Dn +#include + +typedef struct{ + char name[100]; + int age; + int scores[5]; +} student; + +student grade(student st, int grade, int num) { + st.scores[num]=grade; + return st; +} +float average(student st, int no_of_grades){ + float sum=0; + for(int num=0 ; num < no_of_grades ; num++){ + sum += st.scores[num]; + } + + return sum/no_of_grades; + } + +int main(){ + student s1, s2, s3, s4, s5; + strcpy(s1.name, "Sally"); + strcpy(s2.name, "Curtis"); + strcpy(s3.name, "Marianne"); + strcpy(s4.name, "John"); + strcpy(s5.name, "Peter"); + + + s1.age = 15; + s2.age = 16; + s3.age = 17; + s4.age = 100; + s5.age = -1; + + printf("Name: %s\tAge: %d\n", s1.name, s1.age); + printf("Name: %s\tAge: %d\n", s2.name, s2.age); + printf("Name: %s\tAge: %d\n", s3.name, s3.age); + printf("Name: %s\tAge: %d\n", s4.name, s4.age); + printf("Name: %s\tAge: %d\n", s5.name, s5.age); + + s1=grade(s1, 100, 0); + s1=grade(s1, 96, 1); + s1=grade(s1, 99, 2); + s1=grade(s1, 100, 3); + s1=grade(s1, 100, 4); + s2=grade(s2, 94, 0); + s2=grade(s2, 60, 1); + s2=grade(s2, 40, 2); + s2=grade(s2, 94, 3); + s2=grade(s1, 100, 4); + s3=grade(s3, 96, 0); + s3=grade(s3, 100, 1); + s3=grade(s3, 94, 2); + s3=grade(s3, 96, 3); + s3=grade(s3, 100, 4); + s4=grade(s4, 90, 0); + s4=grade(s4, 68, 1); + s4=grade(s4, 81, 2); + s4=grade(s4, 75, 3); + s4=grade(s4, 100, 4); + s5=grade(s5, 90, 0); + s5=grade(s5, 68, 1); + s5=grade(s5, 30, 2); + s5=grade(s5, 75, 3); + s5=grade(s5, 100, 4); + /* + printf("Grade: %d\n", s1.scores[0]); + printf("Grade: %d\n", s1.scores[1]); + printf("Grade: %d\n", s1.scores[2]); + printf("Grade: %d\n", s1.scores[3]); + printf("Grade: %d\n", s2.scores[0]); + printf("Grade: %d\n", s2.scores[1]); + printf("Grade: %d\n", s2.scores[2]); + printf("Grade: %d\n", s2.scores[3]); + printf("Grade: %d\n", s3.scores[0]); + printf("Grade: %d\n", s3.scores[1]); + printf("Grade: %d\n", s3.scores[2]); + printf("Grade: %d\n", s3.scores[3]); + printf("Grade: %d\n", s4.scores[0]); + printf("Grade: %d\n", s4.scores[1]); + printf("Grade: %d\n", s4.scores[2]); + printf("Grade: %d\n", s4.scores[3]); + printf("Grade: %d\n", s5.scores[0]); + printf("Grade: %d\n", s5.scores[1]); + printf("Grade: %d\n", s5.scores[2]); + printf("Grade: %d\n", s5.scores[3]); +*/ + + printf("\n"); + + + printf("Average grade of Sally: %f \n",average(s1, 4)); //average(structure,no. of grades) + printf("Average of Curtis: %f \n",average(s2, 4)); + printf("Average of Marianne: %f \n",average(s3, 4)); + printf("Average of John: %f \n",average(s4, 4)); + printf("Average of Peter: %f \n",average(s5, 4)); + + + return 0; + +} From 25a45a6248355acd6b4f4fe36cd81e1368f503bf Mon Sep 17 00:00:00 2001 From: AvaEN Date: Wed, 6 Jul 2016 19:55:46 -0400 Subject: [PATCH 2/6] Update assignment6.txt --- assignment6.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assignment6.txt b/assignment6.txt index 9526e7c..26218e7 100644 --- a/assignment6.txt +++ b/assignment6.txt @@ -3,6 +3,6 @@ July 6, 2016 Assignment 6: (still working on questions) -1. The function will print: +1. The snippet of code will not function correctly because the struct is in main(). 2. Structures are collections of related variables under a single name. Enumerates define a set of named integer canstants starting from 0. 3. Passing an array directly to a function as an argument. Passing a structure containing an array causes the array to be copied to the function's parameter. From dd76f9b52612c301d9af7e172a11d60e10b33fd0 Mon Sep 17 00:00:00 2001 From: AvaEN Date: Thu, 7 Jul 2016 01:42:00 -0400 Subject: [PATCH 3/6] Update assignment6.txt --- assignment6.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assignment6.txt b/assignment6.txt index 26218e7..4cca73b 100644 --- a/assignment6.txt +++ b/assignment6.txt @@ -1,8 +1,8 @@ Ava N. July 6, 2016 -Assignment 6: (still working on questions) +Assignment 6: -1. The snippet of code will not function correctly because the struct is in main(). +1. The snippet of code will print: 203 1 23 2. Structures are collections of related variables under a single name. Enumerates define a set of named integer canstants starting from 0. 3. Passing an array directly to a function as an argument. Passing a structure containing an array causes the array to be copied to the function's parameter. From 69c5bb1bab658608c2c82734a84db4ddf9abc6b6 Mon Sep 17 00:00:00 2001 From: AvaEN Date: Thu, 7 Jul 2016 10:16:58 -0400 Subject: [PATCH 4/6] Update assignment6.txt --- assignment6.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assignment6.txt b/assignment6.txt index 4cca73b..411ca79 100644 --- a/assignment6.txt +++ b/assignment6.txt @@ -3,6 +3,6 @@ July 6, 2016 Assignment 6: -1. The snippet of code will print: 203 1 23 +1. struct cannot be put inside of main(). But if it is fixed, the snippet of code will print: 203 1 23 2. Structures are collections of related variables under a single name. Enumerates define a set of named integer canstants starting from 0. 3. Passing an array directly to a function as an argument. Passing a structure containing an array causes the array to be copied to the function's parameter. From 4e6960f8c58580f5fde2bec7d011e9117aa3ddc4 Mon Sep 17 00:00:00 2001 From: AvaEN Date: Thu, 7 Jul 2016 10:41:54 -0400 Subject: [PATCH 5/6] Update assignment6.txt --- assignment6.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assignment6.txt b/assignment6.txt index 411ca79..5c1a4a5 100644 --- a/assignment6.txt +++ b/assignment6.txt @@ -3,6 +3,6 @@ July 6, 2016 Assignment 6: -1. struct cannot be put inside of main(). But if it is fixed, the snippet of code will print: 203 1 23 +1. struct cannot be put inside of main(). 2. Structures are collections of related variables under a single name. Enumerates define a set of named integer canstants starting from 0. 3. Passing an array directly to a function as an argument. Passing a structure containing an array causes the array to be copied to the function's parameter. From 56505f2a153c20716afb13889bcf0aee94bde9fb Mon Sep 17 00:00:00 2001 From: AvaEN Date: Thu, 7 Jul 2016 10:44:12 -0400 Subject: [PATCH 6/6] Update banking.c --- banking.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/banking.c b/banking.c index 14e7d60..a83ce58 100644 --- a/banking.c +++ b/banking.c @@ -22,21 +22,21 @@ int main(){ a2.balance = 0; //Deposit part: - printf("How much money do you want to deposit into the %s account? Amount of money in account: %d\n", a1.name, a1.balance); + printf("How much money do you want to deposit into the %s\t account? Amount of money in account: %d\n", a1.name, a1.balance); scanf("%d", &i); a1.balance = a1.balance + i; - printf("How much money do you want to deposit into the %s account? Amount of money in account: %d\n", a2.name, a2.balance); + printf("How much money do you want to deposit into the %s\t account? Amount of money in account: %d\n", a2.name, a2.balance); scanf("%d", &i); a2.balance = a2.balance + i; //Withdrawal part: - printf("How much money do you want to withdraw into the %s account? Amount of money in account: %d\n", a1.name, a1.balance); + printf("How much money do you want to withdraw into the %s\t account? Amount of money in account: %d\n", a1.name, a1.balance); scanf("%d", &i); a1.balance = a1.balance - i; - printf("How much money do you want to withdraw from the %s account? Amount of money in account: %d\n", a2.name, a2.balance); + printf("How much money do you want to withdraw from the %s\t account? Amount of money in account: %d\n", a2.name, a2.balance); scanf("%d", &i); a2.balance = a2.balance - i; @@ -44,7 +44,7 @@ int main(){ printf("\n"); printf("Your Receipt: \n"); - printf("You have %d amount of money in your %s account \n", a1.balance, a1.name); + printf("You have %d dollars in your %s\t account \n", a1.balance, a1.name); printf("You have %d dollars in your %s\t account \n", a2.balance, a2.name); return 0;