Download presentation
Presentation is loading. Please wait.
Published byEllinor Slettebakk Modified over 6 years ago
1
CS113 Introduction to C Instructor: Hubie Chen Web:
2
Administrivia Note: All of this information is on web site!
Class is four weeks Office hours (subject to change!): Thursday 1:30-2:30p, Wednesday 4:35-5:35p Grading: As much as I would like to give all of you A’s, this class is S/U only Prerequisite: CS100 or equivalent I reserve the right to give out quizzes. Keep up with the reading! Assignments once a week (4 total), due on Friday except first one due on Monday (no, silly, that’s one week from today) Turn in printout of program Grades on Assignments: On a scale from = Perfect, 2 = Good, 1 = Incomplete and/or significant errors I guarantee you a S if all assignments completed with score of >= 2, and decent performance on quizzes Failing to complete two assignments results in a U.
3
More Course Details Textbooks: I recommend purchasing both (K&R, Kelley/Pohl) Compiler: I recommend use of Metroworks Codewarrior. Collaboration: You may discuss programs with others, but all code must be your own.
4
Why learn C? “Least common denominator” – good building block for learning other languages Subset of C++, similar to Java Closeness to machine allows one to learn about system-level details (e.g., C only has call-by-value) Portable – compilers available for most any platform!
5
The canonical “first C program”
#include <stdio.h> void main() { printf( “Hello, world!\n” ); }
6
That wasn’t too hard, let’s try another!
#include <stdio.h> void main() { int x = 1, y; int sum; y = 3; sum = x + y; /* adds x to y, places value in variable sum */ printf( “%d plus %d is %d\n”, x, y, sum ); }
7
A minor perturbation… #include <stdio.h> void main() {
int x = 7, y; char id; printf( “Enter a letter, by which I will identify you\n” ); scanf( “%c”, &id ); printf( “Now enter a number!\n” ); scanf( “%d”, &y ); printf( “%c, if nothing else, I know this:” , id); printf( “%d times %d is %d\n”, x, y, x*y ); }
8
Summing the numbers 1 thru 10.
#include <stdio.h> void main() { int i = 1, sum = 0; while( i <= 10 ) sum = sum + i; i = i + 1; } printf( "Sum = %d\n", sum ); for( i = 1; i <= 10; i++ ) { sum = sum + i; } Alternative to while loop! Better, I think.
9
Your Homework Read chapters 1, 2, of Kelley/Pohl, OR chapters 1, 2 of K&R. Write a “hello world” program and some other simple programs in the programming environment which you plan to use.
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.