Transcript Document

CprE 185:
Intro to Problem Solving
(using C)
Instructor: Alexander Stoytchev
http://www.ece.iastate.edu/~alexs/classes/2009_Fall_185/
Introduction and
First Program
CprE 185: Intro to Problem Solving
Iowa State University, Ames, IA
Copyright © Alexander Stoytchev
Outline
• Class Overview
• Syllabus
• First Program
A silly question
• How many of you know how to read and write?
Well, this was not always the case
A silly question
program
• How many of you know how to read and write?
Today programming is becoming a required
skill for many jobs
Language Acquisition
[http://www.wellroundedkids.com/store/Accessories/wooden%20alphabet%20puzzle.jpg]]
[http://www.usm67.org/alphabet/images/alphabet.jpg]
The C Programming Language
• A programming language specifies the words and
symbols that we can use to write a program
• A programming language employs a set of rules that
dictate how the words and symbols can be put
together to form valid program statements
• The Java programming language was developed in
the 1970’s at Bell Labs
• It is one of the most popular and powerful
programming languages used today.
Reserved Words in C
auto break case chart const continue
default do double else enum extern
float for goto if int long register
return short signed sizeof static
struct switch typedef union
unsigned void volatile while
Reserved Words in Java
abstract
boolean
break
byte
case
catch
char
class
const
continue
default
do
double
else
enum
extends
false
final
finally
float
for
goto
if
implements
import
instanceof
int
interface
long
native
new
null
package
private
protected
public
return
short
static
strictfp
super
switch
synchronized
this
throw
throws
transient
true
try
void
volatile
while
Focus of the Course
• This is an intro to problem solving and programming
class (that uses the C programming language)
• The focus is on




problem solving
the logic of programming
program design, implementation, and testing
The fundamentals of programming
What this class will NOT cover
• We will not go into details of programming GUIs
• We will not cover many of the advanced programming
concepts in C
• We will not cover many of the stantard functions and
libraries that come with C
• We will not cover object oriented programming (C++)
This is not…
Warning
• Learning how to program takes a lot of time!
• It also requires a lot of patience.
• You cannot learn how to program by just reading the
textbook. You have to spend long hours in front of the
computer.
• If you want to learn how to program well you will have
to take at least 2-3 other programming classes as
well. This class alone is not enough!
Syllabus
• Posted on the Class Web Page:
 http://www.ece.iastate.edu/~alexs/classes/2009_Fall_185/
REQUIRED
TEXTBOOK
• 5th edition
REQUIRED
TEXTBOOK
• 6th edition
Labs
• Section K: Tuesdays, 10:00 - 11:50am (Coover, room 2018)
• Section E: Tuesdays, 12:10 - 2:00pm (Coover, room 2018)
• Section G: Tuesdays, 2:10 - 4:00pm (Coover, room 2018)
• Section F: Wednesdays, 10:00 -11:50pm (Coover, room 2018)
• Section J: Wednesdays, 12:10 - 2:00pm (Coover, room 2018)
Midterm Exams
• Wed. Sep 22
• Wed. Oct. 28
WebCT
• Submission of Homeworks
• Discussion threads
• Anonymous Course Feedback
First Program
C Program Structure
#include <stdio.h>
int main(int argc, char* argv[])
{
//
comments about the program
printf(“Hello World! \n”);
return 0;
}
C Program Structure
#include <stdio.h>
int main(int argc, char* argv[])
{
All programs must have a main function
}
C Program Structure
#include <stdio.h>
int main(int argc, char* argv[])
{
main function body
Comments can be placed almost anywhere
}
C Program Structure
#include <stdio.h>
int main(int argc, char* argv[])
{
//
comments about the program
printf(“Hello World! \n”);
return 0;
}
Java Program Structure
//
comments about the class
public class MyProgram
{
//
comments about the method
public static void main (String[] args)
{
System.out.println(“Hello World!”);
}
}
Questions/Comments?
THE END