Introduction to Programming Language

advertisement
CSE:141 Introduction to
Programming
Faculty of Computer Science, IBA
BS-I (Spring 2010)
Lesson Plan
• Introduction of the course.
• Methodology used to conduct this course
• Topic to be discussed
– Identify the different components of a computer
– Know about programming languages and their
categories.
– Program Development Process
2/3/2010
Quratulain
2
Course Objective
• Provide solid foundations in the basic
concepts of programming.
• Focuses on common computational problem
solving techniques.
• Use Java for implementation.
2/3/2010
Quratulain
3
Goals
• Develop skills in
– computational thinking
– ability to use vocabulary used in programming
– ability to map described problem into program
that are appropriate for problems that might
occur in practice.
2/3/2010
Quratulain
4
Text/Reference Books
• Java: How to program, Deitel and Deitel
• Programming and problem solving with Java by Nell Dale and Chip
Weems
• Introduction to Programming with Java: A Problem Solving
Approach by John Dean, Park University—Parkville and Ray Dean,
University of Kansas—Lawrence
• Java: An Introduction to Problem Solving and Programming, 5/E by
Walter Savitch
• Kernigan, Brian W. and Dennis M. Ritchie, The C Programming
Language, Second Edition (Prentice-Hall, 1988)
• JAVA for Programmers, Paul J. Deitel and Harvey M., DeitelDeitel
Developer Series, Prentice Hall
• How to Program Using Java by Tony Jenkins and Graham Hardman
Palgrave Macmillan
Java in a Nutshell by David Flanagan, O'Reilly Press
2/3/2010
Quratulain
5
Tentative Topics List
•
•
•
•
•
•
•
•
•
•
•
•
•
•
Overview of programming
Basic control flow
Functions
Overview and Welcome
Problems, Algorithms and Programs
Variables, Values and Types
Arithmetic Expressions
Input and Output (I/O)
Conditionals
Functions
Function Parameters
Iteration
Loop Development
Complex Conditions
2/3/2010
•Functions and Design
•Arrays
•Linear & Binary Search
•Sorting
•Multidimensional Arrays
•Structures
•Strings
•Nested Data Structures
•File Input/Output
•Program Style
•Structuring Program Files
•Recursive Binary Search
•Recursion
•Switch Statement
Quratulain
6
Tools/IDEs
• Java Standard Edition (SE) and JDK 6
• Eclipse
• Netbeans
2/3/2010
Quratulain
7
Web Resources
• http://java.sun.com/j2se/ (Standard Edition)
http://www.eclipse.org
http://java.sun.com/docs/books/tutorial/java/
http://www.javaworld.com
http://jcp.org
http://eclipsetutorial.sourceforge.net/totalbeg
inner.html
2/3/2010
Quratulain
8
Grading Policy
Midterm Exam: 30%
Final Exam:
40%
Quizzes:
10%
Assignments: 10%
Term Project: 10%
2/3/2010
Quratulain
9
Contact Information
Instructor: Quratulain
Office: Room 12, City Campus
Counselling hours: Wednesday and Saturday (2:00 to 5:00)
Cell: 03452324452
Office: 111677677 (ext.1325)
Email: quratrajput@yahoo.com
Website: quratulainrajput.iba.edu.pk
2/3/2010
Quratulain
10
Introduction
• Programs takes input and produce output
according to the described instructions.
• Computer has two major component:
– Hardware(memory, processor, I/O devices)
– Software(system and application programs, compilers)
2/3/2010
Quratulain
11
Software Categories
• A software is the program which contains a list of
instructions that a computer uses in order to function.
– System Programs
• Programs that are needed to keep all the hardware and software
systems running together smoothly.
• Examples: Operating Systems like Linux, Windows, Unix, Solaris,
Mac OS
– Application Program
• Programs that people use to get their work done.
• Examples: Word Processor, Game programs, Spreadsheets
– Compilers
• It is a program to transforms high level code into machine level
that is understandable by machines.
2/3/2010
Quratulain
12
Introduction to Programming
• A programming language is a standardized
communication technique for expressing
instructions to a computer.
• There are different types of programming
languages that can be used to create programs
such as: Java, Pascal, C, C++, C#, visual basic
• To execute a program regardless of any language
instructions are translated into machine language
that can be understood by computers.
2/3/2010
Quratulain
13
Categories of Programming Languages
• High level Languages
– It is more user friendly, to some extent platform-independent, and
abstract from low-level computer processor operations such as
memory accesses.
– A programming statement may be translated into one or several
machine instructions by a compiler. Examples are Java, C, C++, Basic,
Fortran
• Low level
– Assembly languages are similar to machine languages, but they are
much easier to program in because they allow a programmer to
substitute names for numbers, and each instruction is translated into
one machine instruction by an assembler program.
•
Note: the term high level and low level are inherently relative, Originally, assembly language was
considered low-level and COBOL, C, etc. were considered high-level. Many programmers today
might refer to these latter languages as low-level.
2/3/2010
Quratulain
14
Program Development Process
• The basic steps in trying to solve a problem on
the computer are:
– Problem Definition
– Problem Analysis
– Algorithm design and representation (Pseudocode
or flowchart)
– Coding and debugging
2/3/2010
Quratulain
15
Problem Definition
• The problem must be well and clearly defined
first in terms of its input and output
requirements.
• A clearly defined problem is already half the
solution.
• Computer programming requires us to define the
problem first before we even try to create a
solution.
Example
– “Create a program that will determine the number of
times a name occurs in a list.”
2/3/2010
Quratulain
16
Problem Analysis
• After the problem has been defined, the simplest, efficient
and effective approach to solve the problem must be
formulated.
• Usually, this step involves breaking up the problem into
smaller and simpler sub-problems.
Problem:
• Determine the number of times a name occurs in a list
Input to the program:
• list of names
• name to look for
Output of the program:
• the number of times the name occurs in a list.
2/3/2010
Quratulain
17
Algorithms Design and Representation
• An Algorithm is a clear and unambiguous
specification of the steps needed to solve a
problem.
• It may be expressed in either Human language
(English).
• A graphical representation like a flowchart.
• A code representation like a pseudocode.
2/3/2010
Quratulain
18
Expressing Solution Through Human Language
1. Get the list of names
2. Get the name to look for, let's call this the
keyname
3. Compare the keyname to each of the names in
the list
4. If the keyname is the same with a name in the
list, add 1 to the count
5. If all the names have been compared, output the
result
2/3/2010
Quratulain
19
Expressing Solution Through Pseudocode
•
•
•
•
•
•
•
Let nameList = List of Names
Let keyName = the name to be sought
Let Count = 0
For each name in NameList do the following
if name == keyName
Count = Count + 1
Display Count
2/3/2010
Quratulain
20
Expressing Solution Through Flowchart
2/3/2010
Quratulain
21
Coding And Debugging
• Using the algorithm as basis, the source code
can now be written using the chosen
programming language. This process is called
coding.
• The programmer has to add some fixes to the
program in case of errors (also called bugs)
that occurs in the program. This process is
called debugging.
2/3/2010
Quratulain
22
Download