0% found this document useful (0 votes)
78 views

Course Overview and Introduction

This document provides an overview and introduction for an introductory programming course titled "Introduction to Programming (CS113)". The summary includes: - The course is taught by Dr. Kashif Mahmood Rajpoot and includes both lectures and lab components. - The main goals of the course are to understand programming, develop computer programs, and learn the C programming language. - The course runs for 18 weeks and covers various programming concepts like variables, data types, conditional statements, loops, functions, and arrays through lectures and hands-on lab assignments.

Uploaded by

Saad Hamayoon
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views

Course Overview and Introduction

This document provides an overview and introduction for an introductory programming course titled "Introduction to Programming (CS113)". The summary includes: - The course is taught by Dr. Kashif Mahmood Rajpoot and includes both lectures and lab components. - The main goals of the course are to understand programming, develop computer programs, and learn the C programming language. - The course runs for 18 weeks and covers various programming concepts like variables, data types, conditional statements, loops, functions, and arrays through lectures and hands-on lab assignments.

Uploaded by

Saad Hamayoon
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 49

Introduction to Programming (CS113)

BEE-4-ABC
1 – Course Overview and Introduction

Dr. Kashif Mahmood Rajpoot ([email protected])


Assistant Professor, DoC, NUST-SEECS.

http://seecs.nust.edu.pk/faculty/kashif.html
https://www.facebook.com/groups/SEECS.CS105.BEE4ABC/
https://lms.nust.edu.pk/portal/course/view.php?id=4081 (Section A)
https://lms.nust.edu.pk/portal/course/view.php?id=4088 (Section B)
https://lms.nust.edu.pk/portal/course/view.php?id=4095 (Section C)
Computer Programming
o What is a computer?

o What is programming?

o What is a programming language?

o Significance of programming?

2
Learning Goals
o Understand a typical program development
environment

o Become familiar with computer programming

o Develop and write computer program for a given


problem

o Practice a very common programming language


• C

3
Course Design (1+1)
o Components
• Lectures (1 Hours/week)
• Labs (3 Hours/week)
o Lectures
• Concepts of programming
• Examples
• No hands-on programming practice
o Labs
• Hands-on practice
• Lab assignments/exercises
4
Course Design (Cont’d)
o Status
• Introductory
o Class
• BEE-4-ABC
o Credit hours
• 1+1
o Duration
• 18 weeks (15 for study, 3 for exams)
o Pre-requisites
• None
5
Teaching Staff
o Instructor
• Dr. Kashif Mahmood Rajpoot
• Office: A305 (top floor, SEECS faculty block)
• Tel: 051-9085-2172
• Email: [email protected]
• Office hours: 9am-1pm (Friday)

6
Course contents
o Week-1
• Lecture 1: Intro to programming. History of
programming languages. Programming process.
• Lab 1: Programming logic. Pseudo-code. Flow-
charts.
o Week-2
• Lecture 2: Intro to C programming. History of C
language. Basic C program.
• Lab 2: Introduction to programming environment
(Editors, Compilers, Linker, IDE). Program
compilation and execution.

7
Course contents
o Week-3
• Lecture 3: Variables, Data types, Input/Output.
• Lab 3: Code debugging, flow-charts. Data types,
Input/output.
o Week-4
• Lecture 4: Statements, expressions, comments,
operators and precedence.
• Lab 4: Flow-charts. Programming tasks about
operators and precedence.

8
Course contents
o Week-5
• Lecture 5: Conditional statements (decision
structures I).
• Lab 5: Programming tasks about decision
structures I.
o Week-6 (Exam)
• OHT-1

9
Course contents
o Week-7
• Lecture 6: Decision – Switch and break (decision
structures II).
• Lab 6: Programming tasks about decision
structures II.
o Week-8
• Lecture 7: For loops, logical operators (repetition
structures I).
• Lab 7: Programming tasks about repetition
structures I.
10
Course contents
o Week-9
• Lecture 8: While and do-while loops, break and
continue (repetition structures II).
• Lab 8: Programming tasks about repetition
structures II.
o Week-10
• Lecture 9: Nested For loops (repetition structures
III).
• Lab 9: Programming tasks about repetition
structures III.
11
Course contents
o Week-11
• Lecture 10: Scope of variables, static variables.
• Lab 10: Programming tasks about repetition
structures IV and variable scope.
o Week-12 (Exam)
• OHT-2

12
Course contents
o Week-13
• Lecture 11: Function definitions, prototypes,
passing variables (Functions I).
• Lab 11: Programming tasks about functions I.
Project announcement/discussion.
o Week-14
• Lecture 12: More on functions. (Functions II).
• Lab 12: Programming tasks about functions II.

13
Course contents
o Week-15
• Lecture 13: Arrays and array indexing.
• Lab 13: Programming tasks about arrays.
o Week-16
• Lecture 14: Arrays and Functions.
• Lab 14: Programming tasks about arrays and
functions.

14
Course contents
o Week-17
• Lecture 15: Revision and/or additional topics.
• Lab 15: Project Demos.
o Week-18 (Exam)
• End-Semester Examination

15
Books
o Textbook
• C Programming: A Modern Approach
 By K.N. King
 2nd Edition
 W. W. Norton & Company
 “eBook”
o Reference books
• Object Oriented Programming in C++ by Robert Lafore, 4th
Edition
• Beginning C Programming by Ivor Horton.
• Just Enough Programming Logic and Design by Joye Farrell.

o MAKE A HABIT OF READING THE BOOK


• The textbook is easy to read.

16
Course Material
o Books
• E-format
o Lecture slides
• Course website on LMS
o CONSULT THE BOOK, ALWAYS!
o Softwares
• Visual C++ Express 2010
• Visual Logic
 Flow-chart drawing and execution

17
Course Assessment
o Course Part (50%)
• Quizzes – 3 to 4 (un-announced)
• Assignments (2 to 3; home-work)
• OHTs (60 minutes long)
• Final Exam (2/3 hours long)
o Lab Part (50%)
• Project
• Lab Assignments

18
Grading Policy
o Course Part (50% of Total 100 Marks)
• 10% - Quizzes
• 10% - Assignments (home-work)
• 30% - OHTs
• 50% - Final Exam
o Lab Part (50% of Total 100 Marks)
• 70% - Lab Assignments
• 30% - Programming project

19
General stuff
o Prepare in advance for lectures
• Read textbook
o Un-announced quizzes
o Timely submission of assignments
• Late submission = zero (0) marks
o Be punctual in lectures and labs
o Attendance required for sitting in exam – 75%
each in lectures and labs
o NO Copying/cheating/plagiarising assignments
• Carry zero (0) marks
• Disciplinary action
20
Computer Applications
o Computers are everywhere.
• ATMs, Online banks
• NADRA databases, E-government
• Internet
• Games
• Mobile OS/software
• Medical databases
• Weather simulations
• Space explorations

o All of these are enabled by computer programming.


21
Why this course?
o Why to learn programming?
• Shows you how to use the resources and potential of a
computer.
• Shows you how to instruct a computer to perform a
given task.
• Learn how to solve a problem on a computer.
• This has become a very crucial and important course in
electrical/electronic engineering curriculum.
• Many subsequent courses/projects are dependent
upon programming.
• JOB MARKET
22
Programming a Computer
o Programming – giving a machine the directions to
perform a task
o Speed-dial feature on a cell-phone
o Microwave oven configurations
o Similarly, a computer is given directions to perform
a task
• Computer program or simply a program
o Programmer – somebody who writes a computer
program
o Programming languages – variety of languages
used to give directions to a computer
• C, C++, Visual Basic, C#, Java

23
The Programmer’s Job
o Need for solving a problem using a computer: a
programmer comes to the rescue
• Programmer meets the user
• Who is a user?
o Determines the exact problem, agree on the
desired solution
o Converts the solution into a computer program
o Regularly meets the user during the conversion
phase and meet user‟s needs
o Rigorously tests the program using sample data
o Releases the program, often along with a user
manual describing how to use the program
24
History of Programming Languages
o Humans communicate with each other using a
variety of languages
• Urdu, English, French, Hindi, Chinese
• Each language has its own strengths
o Similarly, programmers communicate with
computers using a variety of languages
• C, C++, Java, C#, Python
• Each language has its own strengths for a
particular application

25
History of Programming Languages
o Programming languages have progressed enormously
during last 6-7 decades
o Machine language
• Computers store data and instructions in binary form
 On (1) or off (0)
• Computers can only understand the language of 0s and 1s
• Early programmers wrote programs in the language of 0s
and 1s e.g. a program may contain instruction 00101
10001 10000.
• Instructions written in 0s and 1s are called machine
language or machine code
• Machine code is the only language a computer can
understand
• Understandably, coding in machine language is very tedious,
time-consuming, and error-prone
26
History of Programming Languages
o Assembly language
• Allow the programmer to use pnemonics in place of
0s and 1s
 Pnemonics are memory aids – alphabetic abbreviations
for memory instructions
 e.g. ADD ax, bx
• Programs written in assembly language require an
assembler to convert assembly code to machine
code
 Assembler – a computer program to do code conversion
• Simpler to write assembly code than machine code,
but is still tedious and time-consuming
27
History of Programming Languages
o High-level languages
• Allow programmers to write programs using
instructions that closely resemble English language
 e.g. grossPay = hours * rate
• High-level language programs require a compiler to
convert instructions into 0s and 1s
 Compiler – a computer program to do conversion
• Compiled languages
 C, C++, Visual Basic

28
History of Programming Languages
o Procedure-oriented high-level languages
• Focus on the major tasks the programmer needs to perform
• Instruct the computer every step of the way, from start to
finish
• Programmer focuses and delivers the correct sequence of
instructions to write the program
• C, Basic, COBOL
o Object-oriented high-level languages
• Focus on objects and their interaction needed to write the
program
• An object has some properties and some actions associated
• Objects can be re-used in other applications
• Use a different set of “glasses” to look at the problem
• C++, Java, C#
29
Programming Languages
o Similar to human languages, every
programming language has some rules
governing its word usage and punctuation
o These rules are called the language syntax
o Example: What name is your?
• Most humans, knowing English, can make sense of
this
o But for programming languages, the syntax
needs to be perfect
• Otherwise, computer can not interpret the meaning

30
Programming Languages
o Every programming language needs a software,
compiler/interpreter/assembler, to convert its
code to machine language (or binary code or
object code)
o In addition to conversion, a compiler also
verifies the syntax of the program
• Are there any syntax errors?
• Syntax errors are easy to spot for the compiler
• A message is shown by the compiler, indicating the
error location and type (often)
31
Programming Languages
o Once the program is found free of syntax errors
and is converted to machine code, it can be
executed
• Linking?
o A program, at execution, may or may not
produce correct results
• Programmer must give a correct set of instructions
in a specific sequence
• Must not leave any instructions out, must not add
extraneous instructions
• By doing so, we are developing the logic of program
32
Programming Language: Logic
o Consider a cake recipe:

o Recipe uses correct English syntax, but:


• Wrong sequence of instructions
• Missing instructions
• Extraneous instructions
o Such errors are called logical errors, and are much
more difficult to locate than syntax errors

33
Programming Language: Logic
o Other examples of logical errors:
• Adding 3 eggs, instead of 2 eggs
• Might require a teaspoon of vanilla
o Easy to spot whether „Eggs‟ is spelled correctly, but
very hard to find out the correctness of recipe
o Similarly, it is easy for compiler to locate syntax
errors, but impossible to locate logical errors
o Some program errors are considered to be
semantic errors
• An instruction that does not make any sense in current
context
34
Programming Language
o Errors examples:
• Syntax
• Semantic
• Logical
o Write a program that takes a number (an input
step), doubles it (processing), and tells you the
answer (output step)

35
Understanding the Programming Process
o Programmer‟s job is to write instructions, but a
programmer does not just sit down at a computer
and start typing
o Following steps are followed:
1. Understanding the problem
2. Planning the logic
3. Coding the program
4. Translating into machine language
5. Testing the program
6. Putting the program into production
7. Maintaining the program

36
Understanding the Programming Process

37
1. Understanding the Problem
o Programmer write programs to meet the needs of other
people or organizations
• E.g. HR department, billing department, email program,
video/photo upload, etc.
o As the programmer is providing a service to the user, the
programmer must first understand what its users want
• Example: an inventory control system, a point of sales
system, a photo storage system, a medical record system
• The important decisions on the system are to be made in
consultation with the end-user
o Understanding the problem is one of the most difficult
aspects of programming
o Try to make everything clear about what the user wants
38
2. Planning the Logic
o Heart of the programming process lies in planning the
logic
• Planning a program is also referred as “developing an
algorithm”
• Algorithm – step-by-step instructions to accomplish a task or
solve a problem
o Programmer decides the steps included and their order,
in order to solve the problem
o Planning can be helpful by the use of flowcharts and
pseudo-code
o During the planning, the programmer should not worry
about language syntax
o Planning includes thinking, in advance, about various
inputs and how they are to be processed
39
Planning Logic: Pseudo-code and Flowcharts
o In the planning phase, programmers often use
pseudo-code and flowcharts
o Pseudo-code
• English-like representation of the logical steps it
takes to solve a problem
o Flowchart
• Pictorial representation of the steps to solve a
problem

40
Planning Logic: Pseudo-code
o We have seen examples of pseudo-code earlier
• Nothing mysterious about them, no fixed sytax
• “Free style” English representation
o Writing pseudo-code involves writing all steps
needed to solve a problem
o Flexibility to write
• use small/capital letters
• Start/begin, stop/end
o Use one style consistently
41
Planning Logic: Flowchart
o Flowchart is an alternative way to pictorially
represent the steps of a solution
o Some prefer writing pseudo-code, due to its
similarity with code
o Others prefer drawing flowchart, due to its easy
and simplicity
o There are graphical symbols (i.e. shapes) for
each kind of step
• Start, stop, processing, input, output

42
Planning Logic: Pseudo-code and Flowchart

43
3. Coding the Program
o Once the logic (i.e. algorithm) has been developed,
the programmer can now code it in the language
of his choice
o Only after a language has been chosen, the
programmer should worry about the syntax
o Experienced programmers can develop the logic
and code the program simultaneously
• However, new programmers should focus more closely
on planning the logic in advance. Otherwise, syntax
restrictions can distract you.
o What is more difficult: planning the logic or coding
the program?

44
4. Translating into Machine Language
o Computers can only understand machine
language
o Any modern high-level language needs to be
translated into machine code before it can be
executed
o A program must be free of syntax errors, before
it can be translated

45
5. Testing the Program
o A program successfully translated is free of
syntax errors, but not necessarily free of logical
errors
• E.g. awarding grades based on marks: is the
system awarding the right grades?
o Testing – execute the program with some
sample input data

46
6. Putting the Program into Production
o Once the testing is successful, the program is
ready for release i.e. production
o Putting into production might be as simple as
running it, or could take months (training, etc)
• Microsoft Office
• Exam system, time table scheduling
• Medical record system

47
7. Maintaining the Program
o Post production, any further changes required
or troubleshooting is maintaining the program
o Maintenance is required for many reasons:
• Bug fixes
• Change of rates (tax, prices, etc)
• Change in user needs
o Frequently, new professional programmers are
required to maintain previously written
programs
• Generally, you repeat the development life cycle

48
Book References
o Chapters 1 & 2: Just Enough Programming
Logic and Design

49

You might also like