From eb9255e54df4b769a4b6a5317504d8bdc8658110 Mon Sep 17 00:00:00 2001 From: Haldrup-tech Date: Thu, 29 Aug 2024 15:15:33 -0400 Subject: [PATCH] example code from class --- csci218/Lect/ex3InClass.c | 32 +++++++++++++++++++++++++++++++ csci218/Lect/ex3InClass.out | Bin 0 -> 33472 bytes csci218/Lect/ex5InClass.c | 37 ++++++++++++++++++++++++++++++++++++ csci218/Lect/ex5InClass.out | Bin 0 -> 33440 bytes 4 files changed, 69 insertions(+) create mode 100644 csci218/Lect/ex3InClass.c create mode 100755 csci218/Lect/ex3InClass.out create mode 100644 csci218/Lect/ex5InClass.c create mode 100755 csci218/Lect/ex5InClass.out diff --git a/csci218/Lect/ex3InClass.c b/csci218/Lect/ex3InClass.c new file mode 100644 index 0000000..5711bf6 --- /dev/null +++ b/csci218/Lect/ex3InClass.c @@ -0,0 +1,32 @@ +//use onlinegdb.com +// Example 3 +#include + +int main(void) { + /* + // declare an int variable: age + int age; + //declare a string: userName + char userName[100]; + + //ask for the input, + //Good practice: prompt some hint + printf("Enter Name and Age (serperated by space): "); + scanf("%s %d", userName, &age); + + //ask for name + + //ask for age + //display the infomation + + printf("Hello %s\nYou are %d years old.\n", userName, age); + //ask for more than one input + */ + + char letter; + printf("Please give me a letter: "); + scanf("%c", &letter); + printf("your letter is: %c\n", letter); + + return 0; +} diff --git a/csci218/Lect/ex3InClass.out b/csci218/Lect/ex3InClass.out new file mode 100755 index 0000000000000000000000000000000000000000..d5674ab0234414aff592e9e2ac627d23171bc095 GIT binary patch literal 33472 zcmeI5U1(fI6vt;j8qzdP(yEQcmR!L~6-lhkLz-&3$tKt&(u5?{rACHL_GWYIX4mfC zwTX?*Hf_*;JY=ELfC@nr)1p#r!GK630UwG`1FeN1+K8fksOBLcEu`%^bMGd1w`f7Z zr~iSoXU>_KGc&(C`#3X~Zr!+DD1=LpxJlQLYF;5mghnMH)|2iem9n+=`G!3WZ7m$l z7S%aBbdSe*-lm39b~FS!va3~pUv^B`{t61S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-4{cO{>e>LsK1xIen zEx(?dd-O{4-cwbh;jf2+ZRZc}y?pGV_e9-?!@?N6FdjKJaB)qf^N;4r;emA%_sjoZ q>tF1e_3r-i{nFLzeY4XK{N`Hw?1@W#!(*`z<~^$}zr63Tf_4{vn`Zj} literal 0 HcmV?d00001 diff --git a/csci218/Lect/ex5InClass.c b/csci218/Lect/ex5InClass.c new file mode 100644 index 0000000..1c06d30 --- /dev/null +++ b/csci218/Lect/ex5InClass.c @@ -0,0 +1,37 @@ +//Example 5 in Class +#include + +int main(void) { + char nameOfSchool[] = "CofC"; //variable declaration and assignment + int numOfStudent = 10000; //variable declaration and assignment + + /*i ncrease number of student by 1000 */ + numOfStudent += 1000; + + //using compound operators + + + //printf("After one year, the numer of students in Cofc is %d\n", numOfStudentCofC); + printf("After one year, the number of students in Cofc is %d\n\n", numOfStudent); + /* declare integer x, y, z */ + int x, y, z; + x = 0; + y = 2; + z = 3; + /* using compound operators */ + // x = x + 6; + // y = y / 5; + // z = z * 5; + x += 6; + y /= 5; + z *= 5; + + //y = x++; + //int z = ++x; + + + //printf("x = %d, y = %d, z = %d , nameOfAccountHolder = %s \n", x, y, z, nameOfAccountHolder); + printf("x = %d\ny = %d\nz = %d\n", x, y, z); + + return 0; +} diff --git a/csci218/Lect/ex5InClass.out b/csci218/Lect/ex5InClass.out new file mode 100755 index 0000000000000000000000000000000000000000..658df72372509c9ba7beceddba6646636179eef5 GIT binary patch literal 33440 zcmeI5T})g>6vt;jXqJ{wLyU;PHPwb9LakP-3GKo{h13+J#FEx90roDt3QO6K6e!wl z5w$T!RxxQ(6KVb0r8Y69(d9u)q%~1v6w)t!P-0@F5}Gur4>X~8&fU9k*{Xf;!I=C{ za`wzQXXebzZ|*+Mz29A*yOAb@NsyRHvq=@J5Q9RYmJqq5HKbD3S3F+5ySkx{qbo%l zyfSo?$8}z&j#4&OH#M$IYvb)JV?y^+D9lPr(nQLD+7r+nGRgJaTjHCU*1NFJ`&tsK z2rad#A*DYMZ1pd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