0% found this document useful (0 votes)
11 views31 pages

PF - WK 1 - Introduction

Uploaded by

fookyou377
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views31 pages

PF - WK 1 - Introduction

Uploaded by

fookyou377
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

CS 111

Programming Fundamentals

Fall 2023

Course conducted by
Dr. Mohammad Imran
Assistant Professor
Dept. of Cyber Security
CS111 – Programming Fundamentals 2

Motivation
▪ Why are you pursuing this degree?
• Better job/career prospects
• Social obligation!
▪ Why are you studying this course?
• If you want to secure a computer system, you should know how a
computer works
• Attackers use software to gain unauthorized access to computers, so
you need to know how software is developed
CS111 – Programming Fundamentals 3

Course Description
▪ This course is aimed at familiarizing the students with programming
concepts, so that they can develop computer programs to solve real
world computing problems
▪ The students will learn the syntax of C++ programming language for
implementing concepts learned in this course
CS111 – Programming Fundamentals 4

Course Learning Objectives (CLOs)


▪ At the end of the course, you are expected to be able to:
• Understand and recognize the syntax of different constructs of
structured programming.
• Understand problem and design logic using programming constructs
• Demonstrate the ability to test, debug, and correct the structured
program
• Apply programming knowledge and design algorithms that solve small-
to- moderate scale computational problems
CS111 – Programming Fundamentals 5

Course Outline
▪ Data types, constants and variables
▪ Control structures
• Conditional execution (if-else, switch)
• Repetition (for and while loops)
▪ Arrays and character strings
▪ Pointers
▪ Structures
▪ Functions
▪ File handling
CS111 – Programming Fundamentals 6

Methods & Tools


▪ Teaching-Learning methods: Lectures and Labs
▪ Language to be used for assignments and labs: C++
▪ Development environment: Visual Studio/Dev
CS111 – Programming Fundamentals 7

How will you be tested & graded?


▪ Quizzes 15%
▪ Assignments 5%
▪ Project 10%
▪ Mid-term exam 25%
▪ Final exam 45%
CS111 – Programming Fundamentals 8

Reference Material
▪ Books
• Starting Out with C++ from Control Structures to Objects by Tony Gaddis
(8th Edition)
• C++ How to Program by Deitel & Deitel (10th Edition)
• Object Oriented Programming in C++ by Robert Lafore (4th Edition)

▪ The Web
• Only limited by your own capacity to search and learn!
• w3schools.com is a good resource for programming stuff
CS111 – Programming Fundamentals 9

Some points to note


▪ Pre-requisites
• Willingness to work hard!
• Initiative and creativity – use your mind to its fullest
▪ This is a tough course!
• But it will make your life easier if you pay attention…
▪ Helping a friend in understanding an assignment is okay
• But offering him/her your assignment is NOT OK
▪ Warning: Copying other’s assignment or quiz is a serious offence
• If I detect a cheating case, all concerned will be penalized
CS111 – Programming Fundamentals 10

The Do’s and Don’ts…


▪ DO…
• Be regular & punctual
• Be respective of the classroom environment
• Participate actively, ask questions!
• Check portal regularly for announcements
• Submit all assessments in time
▪ DON’T…
• Use mobile phone in the class
• Bring snacks or drinks to the classroom
• Hesitate in contacting me for any queries/discussion after class
CS111 – Programming Fundamentals 11

Contact Details
▪ 3rd Floor Faculty Offices
• Consultation hours will be communicated later
▪ Ext. 684
[email protected]
▪ 0321-5015699 – Feel free to WhatsApp, SMS, Call

▪ GCR Code: ysxwtwa


CS111 – Programming Fundamentals 12

Week 1
CS111 – Programming Fundamentals 13

What is a computer?
▪ “Electronic device for storing and processing data, making
calculations, or controlling machinery.” (The Pocket Oxford Dictionary)

▪ “An electronic device that processes data, converting it into


information that is useful to people.” (Peter Norton)

▪ “A programmable, multiuse machine that accepts data – raw facts


and figures – and processes, or manipulates, it into information we
can use.” (Williams and Sawyer)
CS111 – Programming Fundamentals 14

How is a computer different from a calculator?


▪ Calculator is made for a specific, fixed task
• Fixed-program machine
▪ Computers can be used for different tasks by storing different
programs
• Stored-program machine
CS111 – Programming Fundamentals 15

What are computers made up of?


▪ Hardware
• All the physical devices that you see and interact with
Casing
Motherboard
Processor
Mouse
Screen
▪ Software
• The unseen thing executing on the processor
• The set of instructions that tell the computer what to do – the program
CS111 – Programming Fundamentals 16

How does a computer work?


▪ Most modern-day computers follow the Von-Neumann architecture
CS111 – Programming Fundamentals 17

How does a computer work?


▪ Most modern-day computers follow the Von-Neumann architecture
▪ Components of Von-Neumann architecture:
• Input/Output unit
Used to provide data required by the computer program
• Processing Unit
Performs the required computation on data
• Memory Unit
Provides temporary storage for instructions and data
CS111 – Programming Fundamentals 18

So where does software fit in?


▪ If hardware is the body of a computer system, software is the soul!
▪ Majority of people purchase computers because of software!
• They want to send emails, type letters, watch movies, surf the Web…
• Nearly every reason given to purchase a computer is based on software
needs
▪ Software tells the hardware what to do
▪ Two broad types of software:
• System software
• Application software
CS111 – Programming Fundamentals 19

Two types of software


▪ System Software
• Helps the computer perform essential operating tasks and enables the
application software to run
The Resource Manager!
CS111 – Programming Fundamentals 20

Two types of software


▪ Application Software
• Enables you to perform specific tasks. e.g:
Word Processing
Photo Editing
Creating web pages
Computer games
Developing software…
CS111 – Programming Fundamentals 21

How is software developed?


▪ The word of development mostly comes with another word: design
• We usually say “software design and development”
▪ The design part is very important. Think about building a house…
• Can you start making walls without first designing the map??? No!
▪ Similarly, before starting to write a computer program, we first need
to work on its design
CS111 – Programming Fundamentals 22

Software design and development process


▪ Designing a software takes many steps
1. Understanding the problem
The problem should be clear and without any ambiguities
2. Identifying the inputs required by the software, the computations to
be performed, and outputs to be generated by the software
3. Breaking down the problem into smaller problems
4. Visualizing the design in the form of a diagram (a flowchart)
5. Writing the algorithm in pseudo-code
Algorithm: A step-by-step description of performing a task
6. Verifying the working of the algorithm (dry-running)
7. Implementing the algorithm using a programming language
CS111 – Programming Fundamentals 23

How is software implemented?


▪ Once you have an algorithm in pseudo-code, you can implement it
▪ The following steps are used for implementation
• Typing the code in a programming language using a text editor
• Compiling the code using a compiler
• Linking the code with the required libraries
• Executing the code using a loader
• Finding and removing errors from the code using a debugger
▪ All these steps require different software tools!
▪ Here comes Integrated Development Environment (IDE)
• An IDE is a collection of software tools which allow you to perform all
above steps (and more…) at one place
CS111 – Programming Fundamentals 24

How is software implemented?


Commonly called the source file
YourCode
.cpp
Commonly called Library Code
Compiling
OtherCode
.obj YourCode
.obj

Linking

YourCode
.exe
The output program
CS111 – Programming Fundamentals 25

Entering and editing a program


▪ For programming we first need a programming language
▪ Just like usual languages, a programing language mainly consists of:
• Vocabulary (set of keywords)
• Grammar (set of rules)
▪ There are many programming languages
• C++, Python, Java, FORTRAN, Assembly…
▪ Which programming language to use?
• Usually depends on the type of software that we want to develop
CS111 – Programming Fundamentals 26

Types of programming languages


▪ Machine Code (low level)
• Language understood by the processor!
• Only contains (hexadecimal) numbers
• Example:
B8 08 00 00 00 83 C0 07
CS111 – Programming Fundamentals 27

Types of programming languages


▪ Assembly language
• An intermediate level language used by experienced programmers for
developing system software
• Contains English-like abbreviations representing elementary computer
operations
• Example:
mov eax, 8
add eax, 7
CS111 – Programming Fundamentals 28

Types of programming languages


▪ High level languages
• Programming languages that can be read and understood by humans
• C/C++/C#, BASIC, PASCAL
• Example:
Total_Pay = No_of_hours * Pay_per_hour;
CS111 – Programming Fundamentals 29

Compiling
▪ Compiling is the process of converting a program in high level
language to machine code
▪ It is a multi-step process
• Parsing the text – separating words and seeing what they represent
• Syntax-checking – making sure that the code follows language rules
• Translation into machine code
▪ The output of this process is an object file
• This file is in machine code but not actually executable
• Executable: A program that can be run on a computer
CS111 – Programming Fundamentals 30

Linking
▪ Almost all computer programs use some other programs that have
been already developed and tested by others
• Code reuse
• Benefit?
Saving of time and effort
▪ Linking is the process of linking the object files of other programs
with your program
▪ The output is an executable file

You might also like