Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
17 views

Programming 1

Uploaded by

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

Programming 1

Uploaded by

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

Programming Fundamentals

ME1042
Lesson-1
BY
DR. (MRS.) K. GALAPPATHTHI
Module Details:

Module Objectives:

This module introduces core programming fundamentals and applies those to solve real-world problems

Credits: 2.0

GPA/NGPA: NGPA
Method of Assessment: Continuous Assessments 40%
End Semester Examination 60%

ME1042 Lesson-1 PROGRAMMING FUNDERMENTALS 2


Learning Outcomes
After successful completion of the module, the learner should be able to

LO-1 : Identify real-world problems and different approaches to solve


LO-2 : Interpret the role of programming languages in solving problems.
LO-3 : Explain the behaviour of simple programs.
LO-4 : Create simple algorithms for solving simple problems using pseudocode and flowcharts.
LO-5 : Use the appropriate data structure for modelling a given problem.

ME1042 Lesson-1 PROGRAMMING FUNDERMENTALS 3


Learning Outcomes..
LO-6 : Apply appropriate conditional and iteration constructs for a given programming task.
LO-7 : Apply the techniques of decomposition to break a program into smaller pieces.
LO-8 : Write programs that use primitive data types, variables, expressions, and command line I/O.
LO-9 : Write programs that use conditional and iterative control structures, functions, and parameter
passing
LO-10 : Write programs using the standard libraries available with a chosen programming language.

ME1042 Lesson-1 PROGRAMMING FUNDERMENTALS 4


References
 Learning Python, 5th Edition by Mark Lutz Publisher: O'Reilly Media, Inc ISBN: 978-1-449-35573-9

 Python in a Nutshell, 3rd Edition Publisher: O'Reilly Media, Inc ISBN: 9781491913833

ME1042 Lesson-1 PROGRAMMING FUNDERMENTALS 5


What is Programming?
Layman’s View of a program

 Agenda, Recipe – Program

Programming - Act of creating a Program.

Program - A set of tasks that would be performed in an activity.


ME1042 Lesson-1 PROGRAMMING FUNDERMENTALS 6
A ComputerProgram
 A computer program is a collection of instructions that
performs a specific task when executed by a computer.
 In 1945 John von Neumann outlined the architecture of the
modern computer with a “Stored Program Concept”.
 In this the program contains a one-at-a-time
sequence of instructions that the computer follows.

ME1042 Lesson-1 PROGRAMMING FUNDERMENTALS 7


Stored ProgramConcept

UNIT1 - PROGRAMMING INTRODUCTION TO PROGRAMMING 8


Computer Programming

Programming a Computer to do work


Benefits
 Fast
 Accurate & Reliable
 Interactive
 Programmable
 Versatile

ME1042 Lesson-1 PROGRAMMING FUNDERMENTALS 9


Solving Problems using a Computer

Real World
Computer Solutions
Problems
1267650600228229401496703205
? 376
2^100

Instructions to Solve
Program
Problems

ME1042 Lesson-1 PROGRAMMING FUNDERMENTALS 10


Programming

The core activity in the process of instructing a computer in


what to do known as programming.

Program
An ordered set of instructions given to a computer to
accomplish a given task is known as a program.??

[ Programming is the art of designing, coding,


modifying and testing programs.]
ME1042 Lesson-1 PROGRAMMING FUNDERMENTALS 11
Man-machine Communication

 You need a language


to communicate with
a computer.
 Computers’ Language is
 English is a Natural Language Machine Language.
 Alphabet: A..Z  Alphabet: 0, 1
ME1042 Lesson-1 PROGRAMMING FUNDERMENTALS 12
Man-Machine Communication …

 Conveying human thoughts to a computer is not easy.

 Human beings are intelligent. They mainly use Natural


Languages in exchanging ideas among them.

 Computers are dumb. They have to be programmed to


work.

ME1042 Lesson-1 PROGRAMMING FUNDERMENTALS 13


Man-Machine Communication …

 Humans use natural languages and computers do


not understand them.

 Computers use machine language and humans do


not understand it.

ME1042 Lesson-1 PROGRAMMING FUNDERMENTALS 14


Man-Machine Communication …

 So, We need a new language which is


easily understood by both humans and
computers.
 These languages are called High Level
Programming Languages.
 All High Level Programming Languages use
Translators to convert human instructions to machine
instructions.

ME1042 Lesson-1 PROGRAMMING FUNDERMENTALS 15


Man-Machine Communication …

Source Code Object Code


print(2 + 3) <0,1> 5
Translator
High Level Machine
Language Language

Compiler - Translates whole program


at once and executes
Interpreter - Translates one
instruction at a time and executes.
ME1042 Lesson-1 PROGRAMMING FUNDERMENTALS 16
Man-Machine Communication …

High Level Machine


Code Code
High Level
Translators
Languages
Compiler: A compiler is a systems software that translates the complete
source code written in high level language into machine code
and then executes it.
Interpreter: An interpreter is a systems software that translates the source
code written in a high level language, into machine code one
instruction at a time and executing it.
ME1042 Lesson-1 PROGRAMMING FUNDERMENTALS 17
What is a Programming Language?

 A formal language for describing


computation?
 Syntax + semantics?
 Compiler, or interpreter, or translator?
A programming language is a formal notational
system for describing computation in a machine-
readable and human-readable form.

ME1042 Lesson-1 PROGRAMMING FUNDERMENTALS 18


Programming Paradigms

Imperative : program = algorithms + data: good for decomposition

Functional : program = mathematical functions: good for reasoning

Logic programming : program = facts + rules : good for searching

Object-oriented : program = objects + messages : good for modeling

ME1042 Lesson-1 PROGRAMMING FUNDERMENTALS 19


Generations of Programming Languages
5th Generation AI

UNIT1 - PROGRAMMING INTRODUCTION TO PROGRAMMING 20


Generations of Programming Languages…
Generation Pros Cons Examples

1st Generation No translation needed Very difficult to use


Machine
(Machine Code) Execution is fast Machine dependent Code
2nd Simple translation High development effort Assemb
Generation Execution if fast Machine dependent ly
(Assembly) Langua
ge
3rd Generation Easier to use Need complex translation C, C++, Java,
(Procedural) Machine independent Efficiency is low Python

4th Generation Even a laymen can use Limited functionality


SQL
(Non Need not say HOW to Very low effciency
Procedural) process
5th Generation Has intelligent features Very limited applications
PROLOG,
(Artificial Powerful interpreters Difficult to understand LISP
Intelligence)

UNIT1 - PROGRAMMING INTRODUCTION TO PROGRAMMING 21


Machine Oriented Languages
 Machine language is an extremely difficult.

 Machine language is tedious, because so much of program code is


needed to accomplish even simple tasks.

 One should know the internal mechanism of the Processor thoroughly


to work with it.

 Machine language also differs from Processor to Processor and is


difficult to read and modify.
ME1042 Lesson-1 PROGRAMMING FUNDERMENTALS 22
Assembly Language

 To make the programmer’s job little easier, another type


of programming language called Assembly Language
was developed.
 An instruction in assembly language is in an ‘easy
to remember’ form called a mnemonic.

ME1042 Lesson-1 PROGRAMMING FUNDERMENTALS 23


Getting Closer to Natural Languages
 Human thoughts originate in its natural form. Natural languages (English,
French, Germen, etc.) play the major role in expressing human ideas.
Therefore the development of computer languages those closely
resemble natural languages was essential to program computers. Such
languages are commonly known as High-level languages.

 Some examples of high-level languages are PL/I, COBOL, FORTRAN,


ALGOL 60 LISP, APL, SIMULA 67, Modula-2, Smalltalk, Prolog, BASIC
and Pascal Java.

 In contrast to high-languages, machine language and assembly


language are known as Low-level languages.
ME1042 Lesson-1 PROGRAMMING FUNDERMENTALS 24
1957 FORTRAN
1958 ALGOL
1959 COBOL by (CODASYL)
Conference on Data Systems
1960 Languages
LISP
1962 APL
1962 SIMULA
1964 BASIC
1970 PROLOG
1972 C
1975 Pascal
1986 C++
1991 Python
1995 JAVA
ME1042 Lesson-1 PROGRAMMING FUNDERMENTALS 25
ProgramTranslation
3 options

 Natively compiled
languages
 Interpreted languages
 Hybrid languages

UNIT1 - PROGRAMMING INTRODUCTION TO PROGRAMMING 26


Natively CompiledLanguages

Compiler(s) built for it convert the source code to native code (machine
code). Large software are written in such languages.
E.g., Office suites, IDEs, Compilers, Games, Time and Mission critical
applications
UNIT1 - PROGRAMMING INTRODUCTION TO PROGRAMMING 27
InterpretedLanguages

The source code is executed line by line by a software called


interpreter. Often slow than the compiled languages because of a
number of reasons.

UNIT1 - PROGRAMMING INTRODUCTION TO PROGRAMMING 28


HybridLanguages
 Source code is converted to an intermediate language
that is embedded in a executable or any sort of file.
 Then the virtual machine or interpreter executes the
intermediate language during the runtime of the application.
 This methodology proved to improve the
performance of interpreted languages

UNIT1 - PROGRAMMING INTRODUCTION TO PROGRAMMING 29


HybridLanguages

UNIT1 - PROGRAMMING INTRODUCTION TO PROGRAMMING 30


Compiled vsInterpreted

UNIT1 - PROGRAMMING INTRODUCTION TO PROGRAMMING 31


Summery
What is Programming?
What is computer programming?
Benefits of Computer Programming
Solving Problems using a Computer
Man-machine Communication
What is a Programming Language?
Programming Paradigms
Generations of Programming Languages
Program Translation

ME1042 Lesson-1 PROGRAMMING FUNDERMENTALS 32

You might also like