CS 101 Problem Solving and Structured Programming in C
120 likes | 300 Vues
CS 101 Problem Solving and Structured Programming in C. Sami Rollins srollins@mtholyoke.edu Spring 2003. Introduction. What is computer programming? What is this class about? Who should take this class?. Administrative Information. Class web page
CS 101 Problem Solving and Structured Programming in C
E N D
Presentation Transcript
CS 101Problem Solving and Structured Programming in C Sami Rollins srollins@mtholyoke.edu Spring 2003
Introduction • What is computer programming? • What is this class about? • Who should take this class?
Administrative Information • Class web page http://www.mtholyoke.edu/courses/srollins/cs101/
Assignments • Reading – Chapter 1 • Homework 0 – due Monday
Computer Hardware • Main memory • Secondary memory • CPU • Input devices • Output devices
Computer Software • Operating system • Examples? • Applications • Examples? • How is a new application developed?
Computer Programs • At the lowest level – machine instructions • 00000111000 • One step up – assembly language • ADD A • More user friendly – high level languages • C = A + B; • Examples?
Translation • High level language must be translated into a language the computer can understand High-level Code Compiler Machine Instructions
Writing Programs • Understand requirements • Write an algorithm • Implement your algorithm • Test your code
What is an algorithm? • A specific set of instructions • An algorithm to make a PBJ sandwich?
Hello World /* * Name: Sami Rollins * Source file name: hello.c * My first "hello, world" program in C. */ #include <stdio.h> //the main function int main (void) { //print the phrase printf("Hello, world!"); return(0); }
Errors • You WILL have errors in your programs • Syntax Errors • Compiler doesn’t understand code • Ex. – printf(Hello, world!”); • Sometimes error messages don’t match problem • Logic • Program runs, but doesn’t do what you want • Ex. – printf(“Hell, world!”); • Can be hard to track down