Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Introduction To Programming

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 37

Introduction to

Programming Concept
Why understanding programming languages is essential
in the digital age.
What is a Programming Language?

Definition of a programming Importance in modern


language technology

A set of instructions that computers Driving software development,


understand and execute, enabling powering applications, and shaping
humans to communicate with the digital landscape.
machines
Primary Classification of Computer
Languages

Machine Assembly High-level


Languages Languages Languages
Machine Languages
the only language a computer is capable of understanding

Definition Importance
lowest-level programming language Fundamental for computer operation;
consisting of binary code directly every program ultimately runs as
executed by a computer's central machine code.
processing unit (CPU)
Assembly language

Definition Importance
Assembly language is a low-level Provides a more human-readable
programming language closely related representation of machine code,
to machine language but uses enabling programmers to write code at a
mnemonics and symbols to represent lower level than high-level languages
instructions.
High-level Languages

Definition Importance
High-level languages are user-friendly Enhances productivity, readability, and
programming languages with high-level portability; enables complex tasks
abstractions from machine code, making without dealing with low-level
it easier for programmers to write code. hardware details.
How Programming Languages Work
01 02 03 04
Source Code Assembly Code Object Code Executable Code

PreProcesso
Compiler Assembler
r
Link Editor
Preprocessing Compilation Assembly Linking

convert source code in expanded source to convert assembly source convert object code to
expanded assembly code to object code executable code
source code source code
What is
assembler,compiler
?
Assembler
Helps computers understand really basic instructions.

It takes simplified human-readable code (assembly language) and


converts it into the 1s and 0s that computers understand directly (machine
code).
Compiler
super-smart assistant

It takes the entire set of instructions written in a high-level language (like


Python or C++) and translates them into a machine level language, all at
once.
It creates an executable file that you can run anytime.
Interpreter
friendly guide

It reads and executes your high-level code line by line, translating and
running each command as it goes. It's great for testing small bits of code
and seeing immediate results.
Interpreter vs Compiler vs Assemble

Interpreter Compiler Assembler


(Python ,Perl,Ruby) (C,C++,Java) (Assembly Language)

Translates high-level language Translates high-level language Translates assembly language into
into machine code into machine code machine code

Translates source one line at a Translates all code at the same Uses the processors instruction set to
time time convert

Returns a list of errors found Will only inform you of the first
and on which lines error it finds

Runs more slowly as it is being Once compiled runs quickly but Runs quickly as conversation between
translated every time the code compiling can take a long time two low level languages is just reliant on
is run the processors instructions set
Types of Programming Languages

01 02
Procedural Languages Object-Oriented Languages
Based on procedures or routines; follow Organize data as objects and methods to
a linear flow of control. manipulate these objects.

03 04
Functional Languages Scripting Languages
Treat computation as the evaluation of
Interpreted languages for automating the
mathematical functions; avoid changing
execution of tasks.
state and mutable data.
Popular programming languages
Known for readability and versatility; used in web development, data
Python analysis, artificial intelligence, and more.

Platform-independent language; widely used for building


Java
enterprise-scale applications.

High-performance language often used in game


C++
development and system/software development.

JavaScr Essential for web development; enables interactive and


ipt dynamic web pages.
Syntax and Semantics in
Programming
Understanding Syntax and Semantics in Programming
Why syntax and semantics?
When writing programs, you have to take care of

Semantics - Meaning of your program


Syntax - Specifying your algorithm using a
programming language

Problem Algorithm Program

Computational Thinking
Semantics Programming
Syntax
What is syntax and semantics?

Syntax refers to the structure of programming languages, the rules that


define how programs are written.

Semantics, on the other hand, deals with the meaning behind the code,
ensuring that instructions are executed correctly.
syntax
Syntax in programming refers to the set of rules that dictate how
programs should be written.

Think of it as the grammar of a programming language; it defines


the correct arrangement of symbols, keywords, and operators.

Components of Syntax:

1. Keywords: Reserved words with specific meanings (e.g., if, else, while).
2. Operators: Symbols representing computations (e.g., +, -, *, /).
3. Variables: Containers for storing data, named using letters and digits.
4. Punctuation: Symbols like semicolons (;) and parentheses () used for
structuring code.
5. Expressions: Combinations of variables, operators, and keywords that
produce a value.
Why syntax is important?

Syntax errors occur These errors prevent Identifying and correcting


when code doesn't the program from syntax errors is one of the
follow the language running. first steps in
rules. programming.
Syntax Rules in Programming

Syntax rules are the precise instructions governing how code should
be structured.

Following these rules ensures that the code is readable and


understandable by both humans and computers.

Common Syntax Rules:

1. Statement Termination: Statements are terminated by semicolons (;).


2. Indentation (in some languages like Python): Proper indentation defines code
blocks.
3. Variable Naming: Variables must have meaningful names, following a specific
pattern (e.g., camelCase, snake_case).
4. Brackets: Opening and closing brackets must match (e.g., {}, [], ()).
Importance of Syntax Rules

Readability Compatibility
Consistent syntax enhances Following language-specific
code readability, making it rules ensures compatibility
easier to understand and across different platforms and
maintain versions.
Understanding Syntax is
the First Step in Writing
Code!
semantics
Semantics in programming focuses on the meaning behind the
code.

While syntax ensures the code's structure is correct, semantics ensure


it behaves as intended.

Understanding Semantics:

● Semantics defines what the program should do.


● It ensures that the program performs the desired operations and produces correct
results.
● Semantics involve understanding the purpose of variables, functions, and the
overall algorithm.
Importance of Semantics

Correctness Efficiency Debugging


Proper semantics lead Understanding Knowledge of semantics
to correct program semantics helps aids in pinpointing and
behavior, ensuring the optimize code for fixing logical errors, a
program does what it is efficiency, making crucial aspect of
supposed to do. programs run faster and debugging.
use fewer resources.
Programming Design Tools
● Programming design tools are the building blocks of every
software application.
● They provide a structured approach to problem-solving, allowing
developers to visualize, plan, and implement solutions
systematically.
● Focus on three key tools: Algorithms, Flowcharts, Pseudocode.
Algorithms
● A step-by-step procedure or formula
designed for solving a problem or
accomplishing a task.
● Algorithms are the heart of computer
science, guiding computers in performing
specific tasks efficiently.
Characteristics of a Good Algorithm:

Clarity Finiteness Language


Independent

Input Output Feasibility


Properties of Algorithm:
● It should terminate after a finite time.
● It should produce at least one output.
● It should take zero or more input.
● It should be deterministic means giving the same output for the same input case.
● Every step in the algorithm must be effective i.e. every step should do some work.
Examples

Sorting and Machine


Search Engines Ranking Learning
Google Search Search Engine Result Algorithms
Algorithm Page Ranking Neural Networks,
Decision Trees
Write an algorithm to determine a
student’s final grade and indicate
whether it is passing or failing. The
final grade is calculated as the average
of four marks.
Background
A typical programming task can be divided into
two phases:

Problem solving phase


• produce an ordered sequence of steps that describe
solution of problem
• this sequence of steps is called an algorithm

Implementation phase
• implement the program in some programming
language
Flowchart
A graphical representation of the sequence of operations in
an information system or program.
Usages
Information system flowcharts show
how data flows from source documents
through the computer to final
distribution to users.
Program flowcharts show the sequence
of instructions in a single program or
subroutine.
Different symbols are used to draw
each type of flowchart.

You might also like