diff --git a/csci218/Lect/ex6inClass.c b/csci218/Lect/ex6inClass.c new file mode 100644 index 0000000..0351afb --- /dev/null +++ b/csci218/Lect/ex6inClass.c @@ -0,0 +1,40 @@ +/* simple statement example ex6InClass.c +By Dr. Xu +This program is for explaining the building blocks of C +*/ + +# include //For accessing the standard library functions +# include + +int main() { + /* literals: 5, 6, 3, 3.14, "James", '!' + Variables: a, b, c, name, punc + Constant: PI + Expressions: a + b * 3, a + 6 + function: printf() + datatype: int, char, float + */ + + //variable declaration ; + // variable assignment + int a, b; // variable assignment + //variable declaration and initialization + a = 5; + b = a + 5; + float c = 1.5; + + const float PI = 3.1415926; + + c = PI * pow(b, 2.0); + + + printf("a = %d\nb = %d\nc = %.3f\nPI = %.3f\n", a, b, c, PI); + + char stName[] = "James"; + char punc = '!'; + + printf("Good Bye, %s%c\n", stName, punc); + + //printf("Good bye, %s %c \n", name, punc); + return 0; +} diff --git a/csci218/Lect/ex6inClass.out b/csci218/Lect/ex6inClass.out new file mode 100755 index 0000000..30f351d Binary files /dev/null and b/csci218/Lect/ex6inClass.out differ