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 0000000..d5674ab Binary files /dev/null and b/csci218/Lect/ex3InClass.out differ 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 0000000..658df72 Binary files /dev/null and b/csci218/Lect/ex5InClass.out differ