0% found this document useful (0 votes)
58 views36 pages

COMP102 Introduction To Programming Slides - 160380

This document serves as an introduction to programming, covering fundamental concepts such as what programming is, the role of programmers, and the types of programming languages. It discusses the importance of learning programming for personal and professional growth, as well as the different types of programming languages and their characteristics. Additionally, it provides an overview of C++ and its applications, along with the expected outcomes of the course.

Uploaded by

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

COMP102 Introduction To Programming Slides - 160380

This document serves as an introduction to programming, covering fundamental concepts such as what programming is, the role of programmers, and the types of programming languages. It discusses the importance of learning programming for personal and professional growth, as well as the different types of programming languages and their characteristics. Additionally, it provides an overview of C++ and its applications, along with the expected outcomes of the course.

Uploaded by

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

INTRODUCTION

TO
PROGRAMMING
Lec 1.
Dr.Ifra AFZAL
CONTENTS:
◦What is program?
◦What is programming?
◦Why we need to learn programming?
◦What does a programmer do?
◦What is programming language?
◦What types of programming languages?
◦What is language translators?
◦What types of codes are?
03/09/2025
CONTENTS:
◦What is Syntax?
◦Types of error
◦What is C++?
◦Why C++?
◦Who uses C++?
◦What can we do?/By the end of course.

03/09/2025
Video Link
◦ https://www.youtube.com/watch?v=Wchru8alhaE&list=PPSV

03/09/2025
WHAT IS PROGRAM?
◦ A program is a set of instructions that tells a computer what to do. It serves as
a way to communicate with the computer to perform tasks, solve problems, or
create interactive applications.

◦ A program can instruct the computer to:


◦ Display message on screen
◦ Get input from users
◦ Perform arithmetic operations
◦ Compare values
◦ Perform iterations
03/09/2025
WHAT IS PROGRAMMING?
◦ Programming is defined as the process of creating
computer software using a programming
Language. Computer programs are written by
Human individuals(Programmers).

◦ A computer program is a step by step set of


instructions that a computer has to work through
in a logical sequence in order to carry out a
particular task. The computer executes these
instructions (obeys the instructions) when told to
do so by the user.
03/09/2025
WHY WE NEED TO LEARN PROGRAMMING?

03/09/2025
Personal Reasons:
Creativity: Build your own apps, games, or tools.
Career Advancement: Tech jobs are in high demand globally.

Broader Impact:
Innovation: Programming drives breakthroughs in AI, robotics, and medicine.
Efficiency: Automates manual processes, saving time and resources.

Relevance in Daily Life:


Smart devices (Alexa, Google Home).
Entertainment platforms (Netflix, Spotify).
Tools like GPS and online payment systems.

03/09/2025
WHAT DOES A PROGRAMMER DO?

Translate ideas Identify and fix Work with Develop solutions


into instructions errors in code teams on for challenges,
using e.g., improving
to ensure the large projects
user
programming program runs like apps or
experiences or
languages like smoothly. systems. optimizing
Python, Java, or performance.
C++.

03/09/2025
WHAT IS PROGRAMMING LANGUAGE?
◦ Programming languages are the
vocabulary and set of grammatical
rules for instructing a computer to
perform specific tasks. There are
many different types of
programming languages each having
a unique set of keywords (words that
it understands) and a special syntax
(grammar)for organising program
instructions.

03/09/2025
WHAT TYPES OF PROGRAMMING LANGUAGES?

◦ Programming languages are classified into five major categories: machine


languages (first generation languages), assembly languages (second
generation languages), Procedural Oriented Language (third generation
languages), Object Oriented Language (fourth generation languages), and
natural languages (fifth generation language). Machine and assembly
languages are referred to as low level languages; third generation, fourth
generation and natural languages are categorised as high level languages.

◦ A low level language is machine dependent; that is, it is written to run on one
particular computer. A high level language is machine independent, which
means the high level language code can run on many different types of
computer.
03/09/2025
Programming
Language

Low level High Level


Language Language

Procedural Object
Machine Assembly Natural
Oriented Oriented
Language Language Language
Language Language
(1GL) (2GL) (5GL)
(3GL) (4GL)

03/09/2025
WHAT TYPES OF PROGRAMMING LANGUAGES?

◦Machine language
◦ The machine language writes programs using the machine code i.e.
binary Digits (0 and 1), which is directly understood by the computer.
◦ The main problems with using machine code directly are that it is very
easy to make a mistake, and very hard to find it once you realise the
mistake has been made.
◦ Doesn’t require any language translator.
◦ Program execution is faster as no conversion is required.
◦ Program development is difficult and time-consuming.
◦ Machine dependent (may not run on several other processor)
◦ Detail hardware architecture knowledge is required.
03/09/2025
WHAT TYPES OF PROGRAMMING LANGUAGES?

◦ Assembly language is written using mnemonic codes (abbreviated


English words) or short codes that suggest their meaning and are therefore
easier to remember. These codes represent operations, addresses that
relate to main memory, and storage registers of the computer. Typical
codes might be: LDA, STO, ADD, NOP, etc.

IDA A, 20 : load accumulator A with the value 20


ADD A,
: add the value 10 to accumulator A
10
STO B, A : store contents of accumulator A into storage
register B
NOP no operation (stop here) 03/09/2025
WHAT TYPES OF PROGRAMMING LANGUAGES?

◦ Assembly languages have to be


translated into machine language by
language translators known as assemblers
for the processor to understand.
◦ The assembler program recognises the
character strings that make up the symbolic
names of the various machine operations,
and substitutes the required machine code
for each instruction.
◦ Easier to write than machine language.

03/09/2025
WHAT TYPES OF PROGRAMMING LANGUAGES?

◦ High level programming language is


defined as one that is machine
independent and uses variables and
objects, Boolean expressions, functions,
loops, arrays, threads, locks which are
similar to their meaning (abstraction).
◦ High-level languages reflect the logic and
procedures used in a human algorithm, the
programmer is able to concentrate on
developing task algorithms rather than on
how the computer will carry out the
instructions. 03/09/2025
03/09/2025
WHAT TYPES OF PROGRAMMING LANGUAGES?

◦ Governed by a strict syntax (set of grammatical rules).


◦ Easier to read, write, and maintain.
◦ Faster development of large programs.
◦ Programs written in a high-level language must be translated into machine
language by a compiler or interpreter.

03/09/2025
High
Level
TASK NO.1

Language

Low Level
Language
03/09/2025
WHAT TYPES OF CODES ARE?
◦ Source code is a program code of either an assembly language or high-
level language that the programmers write in a program editor. Source
code cannot be understood by the computer until it has been translated
into machine code.

◦ Object code is a program code in machine readable form (a source


program that has been translated).

03/09/2025
WHAT IS LANGUAGE TRANSLATORS?
◦ Language translators/Language processors
◦ A software that converts programs (High Language) into machine language.
◦ Every computer language has its own translators.

◦ Compiler
◦ Interpreter
◦ Assembler

03/09/2025
WHAT IS LANGUAGE TRANSLATORS?
◦ A Compiler is a program that converts the entire source code(compiles it)
into machine language at one time before the computer can run the
program at a later time.
◦ While compiling the source code into machine code, it checks that the
syntax is properly written by the programmer for the programmer to debug
the program.
◦ C, C++ use the compiler as a language translator.

Source Code
Compile Machine/Object

r Code

03/09/2025
WHAT IS LANGUAGE TRANSLATORS?
◦ The interpreters are programs that translates the high level program
code one statement at a time, that is, it reads a code statement, converts
it to one or more machine language instructions, and then executes the
instruction before moving translating the next code statement in the
program. If there is any error in the statement, the programmer can correct
the error before the interpreter evaluates the next statement. Interpreters
are slower than Compilers because interpreters convert a statement at a
time and runs it before moving to the next line.
◦ Python, Ruby, and PHP use the interpreter as a language translator.

03/09/2025
interpreter
s
Source Code Machine Code

Next
Instruction

03/09/2025
03/09/2025
Interprete
TASK NO.2

ble Co
em mp
s i le
As r r

03/09/2025
WHAT IS SYNTAX?

03/09/2025
WHAT IS SYNTAX?
◦ Syntax refers to the spelling an grammar of a programming language.
◦ Each program defines its own syntactical rules that control which words the
computer understands, which combinations of words are meaningful, and
what punctuation is necessary.
◦ Text-based programming languages are based on sequences of characters.
◦ A set of rules that govern the structure of a programming language,
including the order and combination of symbols, punctuation, and words.
Syntax is important because it ensures that code is written in a consistent
and understandable manner, making it easier to read and execute.

03/09/2025
TYPES OF ERRORS IN PROGRAMMING
◦ Syntax errors
◦ Code doesn't follow the rules of the programming language.
◦ Runtime errors
◦ invalid input, division by zero, or logic errors.
◦ Logical errors
◦ caused by miscalculations in the logic code, such as using the wrong
formula or calling the wrong variables.
◦ Semantic errors
◦ These errors occur when the code doesn't correctly convey the intended
functionality or behaviour. They can be more subtle and complex to
detect than syntax or logic errors.
03/09/2025
TYPES OF ERRORS IN PROGRAMMING
◦ Semantic errors
◦ These errors occur when the code doesn't correctly convey the intended
functionality or behaviour. They can be more subtle and complex to
detect than syntax or logic errors.
◦ Arithmetic errors
◦ These errors involve a mathematical error, such as dividing by zero.
◦ Compilation errors
◦ These errors occur when the compiler doesn't know how to turn the code
into a lower-level language that the computer can understand.

03/09/2025
WHAT IS C++?
◦ C is a programming language developed in the 1 970's alongside the UNIX
operating system.
◦ C provides a comprehensive set of features for handling a wide variety of
applications, such as systems development and scientific computation.
◦ C++ is an "extension" of the C language, in that most C programs are also
C++ programs.
◦ C++, as opposed to C, supports "object-oriented programming."

03/09/2025
WHAT IS C++?
Human Work Model:

Computer Work Model:

03/09/2025
WHY C++?
◦ Bad News:
◦ C++ is not easy to learn

◦ Good News:
◦ Lots of good-paying jobs for programmers
◦ Java uses C++ syntax, it is easy to learn Java if you know
◦ C++ is not the easiest language (Basic and Pascal are easier), it is not the
hardest either (Ada, Prolog and Assembly languages are really difficult!)

03/09/2025
WHO USES C++?
◦ Computer makers such as Sun, SGI, IBM, and HP
◦ Airport
◦ Computer chip manufacturers like Motorola & Intel
Software companies
◦ Banks
◦ Hong Kong Government
◦ Hospital Authority
◦ Telecommunications
◦ Universities
03/09/2025
WHAT CAN WE DO
BY THE END OF THE COURSE?
◦ Program the computer in applications such as the following:
◦ Program a simple calculator
◦ Program simple computer games
◦ Program a small inventory system for a small company

03/09/2025
Cont.…..

03/09/2025

You might also like