Title: CS 192
1CS 192
- Problem Solving and Computer Programming
- Winter 2003
- Instructor
- Dr. Shafay Shamail
- TA
- Adeel Zafar
- Ibrar Javed
2Schedule
3Description
- This first level programming course shall cover
the principles and practice of problem solving
using C. - Students shall be introduced to the basic C
techniques such as program control statements,
pointers, functions, structures etc. - The students shall gain hands-on experience
through several programming assignments.
4Text Books
- Primary
- Herbert Schildt, C from the Ground Up, 2nd
Edition, 1998, Osborne McGraw-Hill. - References
- Deital Deital, C How to Program, 3rd
Edition, 2001, Prentice Hall. - Herbert Schildt, C The Complete Reference,
3rd Edition, 1998, Osborne McGraw-Hill. -
- Some handouts may be given to supplement the text
5- Lectures
- There shall be 30 sessionso 20 sessions of
75 minutes eacho Up to 8 labs of 100
minutes each conducted by TA - Grading
- o 15 Quizzes (quizzes may be based on
assignments)o 10 Programming
Assignments.o 15 Labso 25
Midterm Examo 35 Final Exam
6Topics
7Topics
8Topics
9Scholastic Ethics
- Students are expected to maintain high
standards of academic honesty. The Disciplinary
Committee will deal with breaches in scholastic
ethics such as cheating. - Plagiarism will be suspected if an
assignment that calls for independent development
and implementation of a program results in two or
more solutions so similar that one solution can
be converted to the other(s) by a series of
simple commands - Cheating will be suspected if a student who
completed an assignment independently cannot
explain both the intricacies of the solution and
the techniques used to generate that solution
10Examples of Cheating
- Turning in someone else's work, in whole or in
part, as your own (with or without his/her
knowledge) - Turning in a completely duplicated assignment is
a flagrant offense - Allowing another student to turn in your work as
his/her own - Several people writing one assignment and turning
in multiple copies, all represented (implicitly
or explicitly) as individual work
11Examples of Not Cheating
- Turning in work done alone or with the help of
the course's TAs. - Submitting one assignment for a group of students
if group work is explicitly permitted (or
required) - Getting or giving help about using the computers
- Getting or giving help about solving minor syntax
errors Penalties for cheating can be an 'F' in
the course or worse.
12What is a Computer?
- Computer
- A device capable of performing computations and
making logical decisions - Computer programs
- Sets of instructions that control a computers
processing of data - Hardware
- Various devices comprising a computer
- Examples keyboard, screen, mouse, disks, memory,
CD-ROM, and processing units - Software
- Programs that run a computer
13Computer Organization
- Six logical units in every computer
- Input unit
- Obtains information from input devices (keyboard,
mouse) - Output unit
- Outputs information (to screen, to printer, to
control other devices) - Memory unit
- Rapid access, low capacity, stores input
information - Arithmetic and logic unit (ALU)
- Performs arithmetic calculations and logic
decisions - Central processing unit (CPU)
- Supervises and coordinates the other sections of
the computer - Secondary storage unit
- Cheap, long-term, high-capacity storage, stores
inactive programs
14A Bit of History
- Which was the first programmable computer?
- Charles Babbages Analytical Engine (early
1800s) - First programmer?
- Ada Augusta, Countess of Lovelace Charless
colleague and daughter of Lord Byron
15The Analytical Engine has no pretensions
whatever to originate anything. It can do
whatever we know how to order it to perform. It
can follow analysis but it has no power of
anticipating any analytical relations or truths.
Its province is to assist us in making available
what we are already acquainted with. -Ada
Augusta, Countess of Lovelace
16Evolution of Operating Systems
- Batch processing
- Do only one job or task at a time
- Operating systems
- Manage transitions between jobs
- Increased throughput
- Amount of work computers process
- Multiprogramming
- Many jobs or tasks sharing a computers resources
- Timesharing
- Perform a small portion of one users job then
move on to service the next user
17Personal ComputingDistributed ComputingClient/Se
rver Computing
- Personal computers
- Economical enough for individual
- Distributed computing
- Organizations computing is distributed over
networks - Client/server computing
- Sharing of information, across computer
networks, between file servers and clients
(personal computers)
18Types of Programming Languages
- Machine languages
- Strings of numbers giving machine specific
instructions - Example
- 130004277414005934191200274027
- Assembly languages
- English-like abbreviations representing
elementary computer operations (translated via
assemblers) - Example
- LOAD BASEPAYADD OVERPAYSTORE GROSSPAY
- High-level languages
- Similar to everyday English, use mathematical
notations (translated via compilers) - Example
- grossPay basePay overTimePay
19Some High-Level Languages
- Java used to
- Create web pages with dynamic and interactive
content - Develop large-scale enterprise applications
- Enhance the functionality of web servers
- Provide applications for consumer devices (such
as cell phones, pagers and personal digital
assistants) - FORTRAN
- Used in scientific and engineering applications
- COBOL
- Used to manipulate large amounts of data
- Pascal
- Used to teach structured programming
- C/C
- Middle-level language
- Provides facilities for both high level as well
as low level programming
20History of C and C
- C evolved from C
- C evolved from two other programming languages,
BCPL and B - ANSI C
- Established worldwide standards for C programming
- C invented by Dennis Ritchie of ATT Bell Labs in
the 1970s - C by Bjarne Stroustrup of the same labs in the
early 1980s - C spruces up C
- Provides capabilities for object-oriented
programming - Objects are reusable software components that
model things in the real world - Object-oriented programs are easy to understand,
correct and modify - C is a subset of C
21Structured Programming
- Structured programming
- Disciplined approach to writing programs
- Clear, easy to test and debug, and easy to modify
- Multitasking
- Many activities to run in parallel
22Basics of a Typical C Environment
- Phases of C Programs
- Edit
- Preprocess
- Compile
- Link
- Load
- Execute
Files .cpp, .c, .h .obj, .exe
23 Errors
- Syntax errors
- reported by the compiler
- Linker errors
- reported by the linker
- Execution/Run-time errors
- reported by the operating system
- Logic errors
- not reported
24Introduction to C Programming
- C language
- Facilitates a structured and disciplined approach
to computer program design - C and C are portable languages
- Programs written in C and C can run on many
different computers
25Identifiers in C
- A name assigned to
- A constant
- Variable
- Function
- User defined data type
26Identifiers in C
- Rules
- Can be from one to several characters long
- First 1024 characters are significant
- May consist of alphanumeric and underscore
characters - May start with any letter of alphabet, or with an
underscore - Are case sensitive
- No special characters are allowed
- Spaces are not allowed as part of the identifier
name - Keywords cannot be used as identifiers
- Any other reserved words by the language (such as
names of library functions) shall not be used as
identifiers
27Identifiers in C
- Conventions
- Use identifier names that reflect the meaning or
usage of the items being named - THISISACONSTANT or THIS_IS_A_CONSTANT
- thisisavariable or this_is_a_variable
- thisIsAFunction
- ThisIsAUserDefinedDataType