You are on page 1of 28

Subject Name : Paradigms of Computer Programming and C++

Subject Code : CST-152


Class : Common to all Branches of First Year
Semester : First Year, 2nd Semester
Credits :
L T P Cr Internal Marks External Marks

3 0 0 2 40 60

Prerequisite : Basic C Programming Language Knowledge


Contact Hours : 45

University Institute of Engineering


Paradigms of Computer Programming and C++ Syllabus
Paradigms of Computer
L T P C
Programming and C++
Subject Code: CST- Total Contact Hours : 30
152 Hours
3 0 0 3
Common to all Branches of
First Year
Marks-100
Internal-40 External-60
Course Objectives
To understand the concept of the various Programming ParadigmsTo apply different programming
languages for modeling real world problems.
Unit Course Outcomes
Understand the various paradigms of computer programming
I-III identify the strengths and weaknesses of different programming paradigms
To provide in-depth knowledge of various concepts of programming paradigms

University Institute of Engineering


Unit-1

University Institute of Engineering


Paradigms of Computer Programming and C++ Syllabus
UNIT-1 [15]
• Introduction to different paradigms of programming: Imperative Programming, Object
Oriented Programming, Functional Programming, Logic Programming.
[2]
• Imperative Programming using C++: Introduction to Imperative Programming, Data types, Data
Input and output streams (cin, cout), introduction to namespace. [3]
• Object Oriented Programming using C++: Classes and Objects: Difference between object
oriented and procedure oriented programming, Difference between structure and class, Features of
object-oriented programming, Specifying a class, creating objects, accessing class members,
defining a member function inside and outside class, access specifiers, inline function, static data
members & member functions. Objects as function arguments, friend function and returning objects
to functions. Constructors and Destructors: Need for constructors, types of constructors: default,
parameterized, copy constructor, order of execution of constructors, destructors and their need.
[10]

University Institute of Engineering


Unit-2

University Institute of Engineering 5


Paradigms of Computer Programming and C++ Syllabus

UNIT-2 [15]
• Inheritance: Defining derived class, modes of inheritance, types of inheritance, ambiguity in
inheritance, virtual base class, Function overriding, Member Classes: Nesting of Classes. [4]
• Polymorphism: Introduction & types of polymorphism, Function overloading, operator
overloading, rules for overloading operators, overloading of unary & binary operators, Constructor
Overloading. [4]
• Pointers, Virtual Functions: Declaring & initializing pointers, pointer to objects, this pointer,
pointer to derived classes, static and dynamic binding, dynamic memory allocation: new and delete
operator. [4]
• Exception Handling: Try, Throw, Catch, Throwing an Exception, Catching an Exception. [3]

University Institute of Engineering


Unit-3

University Institute of Engineering 7


Paradigms of Computer Programming and C++
Syllabus
UNIT-3 [15]
• Files: Introduction to File streams, Hierarchy of file stream classes, File operations, File I/O,
File opening Modes, Reading/Writing of files, Random-access to files.
[3]
• Logic Programming: Introduction to Logic & Logic Programming, types of languages used
in logic programming, Examples of Logic reasoning problems.
[6]
• Functional Programming: Introduction to Functional Programming, types of function,
parameter types in function, recursive function, function returning values.
[6]

University Institute of Engineering


References
Text books:
• 1. E Balagurusamy., “Object Oriented Programming in C++”, Tata McGraw-Hill.
• 2. Robert Lafore, “Object Oriented Programming in C++”, Waite Group, December 1998.
Reference Books:
• 1. Herbert Schildt , “C++- The Complete Reference”, Tata McGraw-Hill 2003, New Delhi.
• 2. Bjarne Stroustrup: “The C++ Programming Language” (4th Edition). Addison-Wesley. May
2013.
• 3. Ravichandran , “Programming with C++”,Tata McGraw-Hill Education, 2001.
• 4. Joyce M. Farrell,” Object Oriented Programming Using C++”,Cengage Learning, January
1998.

University Institute of Engineering


Course Objectives
• To understand the concept of the various Programming Paradigms.
• To apply different programming languages for modeling real world
problems.

Different Programming Paradigms Objectives


 To understand the concept of the various Programming Paradigms.
 To apply different programming languages for modeling real world
problems
 To understand what are the various programming technique.
 To know the advantage of object oriented programming over procedural
programming.
Instructions for the Paper-Setter

• Please go through these instructions thoroughly and follow the same pattern while setting the paper as
the students have been prepared according to this format.
• Maximum Marks = 60 Time: 3 Hrs
• Weightage per unit = 20 marks (excluding over attempt weightage)
1. Question Paper will consist of ten questions.
2. Section A of question paper is compulsory, containing five parts each of 2 marks covering the whole
syllabus (short answer type- total 10 marks)
3. Set three questions from each unit I, II and III. Students will attempt 5 questions selecting at least one
question from sections B, C & D. Each question carries 10 marks. Questions of Section B will be from
unit I, Questions of Section C from unit II and Questions of section D from unit III
4. In the question paper, distribution of the questions should be by considering 30 % numerical part and 70
% conceptual.

University Institute of Engineering


Paradigms of Computer Programming
and C++
Subject Code-CST-152
UNIT-I
Chapter-1
Topic Introduction to different Paradigms
Programming
Contents
Introduction to different paradigms of programming:
• Imperative Programming
• Object Oriented Programming
• Functional Programming
• Logic Programming.

University Institute of Engineering


Introduction of Programming
Programming languages provide an abstraction from a computer’s instruction set
architecture
Low-level programming languages provide little or no abstraction,
e.g., machine code and assembly language
Difficult to use
Allows to program efficiently and with a low memory footprint

High-level programming languages isolate the execution semantics of a computer


architecture from the specification of the program
Simplifies program development

University Institute of Engineering 1


Programming Paradigms
Programming languages can be categorized into programming
paradigms:
Meaning of the word ’paradigm’
“An example that serves as pattern or model”
The American Heritage Dictionary of the English Language
Programming paradigms are the result of people’s ideas about how
computer programs should be constructed
Patterns that serves as a “school of thoughts” for programming of
computers

University Institute of Engineering 2


Principal Programming Paradigms
1. Imperative / Procedural
2. Functional
3. Object-Oriented
4. Logic Programming

University Institute of Engineering 3


Imperative / Procedural
Imperative programming is a paradigm of computer programming in which the
program describes a sequence of steps that change the state of the computer.

 To make programs simpler for a human to read and write, imperative statements
can be grouped into sections known as code blocks.

 In the 1950s, the idea of grouping a program's code into blocks was first
implemented in the ALGOL programming language. They were originally called
"compound statements," but today these blocks of code are known as procedures.

This type of imperative programming is called procedural programming,

University Institute of Engineering 4


Imperative / Procedural languages are:
• ALGOL
• Assembly language
• C
• MATLAB etc.

University Institute of Engineering 5


Properties of the imperative paradigm
1. Incremental change of the program state as a function of time.
2. Straight forward abstractions of the way a traditional .
3. Similar to descriptions of everyday routines, such as food recipes and
car repair
4. Language representatives
1. Fortran, Algol, Pascal, Basic, C

University Institute of Engineering 6


Functional programming
Functional programming languages are specially designed to handle symbolic
computation and list processing applications. Functional programming is based on
mathematical functions. Some of the popular functional programming languages
include: Lisp, Python etc.

Functional programming languages are categorized into two groups, i.e. −

i) Pure Functional Languages − These types of functional languages support only the
functional paradigms. For example − C.
ii) Impure Functional Languages − These types of functional languages support the
functional paradigms and imperative style programming. For example − LISP.

University Institute of Engineering 7


Properties of Functional programming
1. The most prominent characteristics of functional programming are as follows −
2. Functional programming languages are designed on the concept of mathematical
functions that use conditional expressions and recursion to perform computation.
3. Functional programming languages don’t support flow Controls like loop statements
and conditional statements like If-Else and Switch Statements. They directly use the
functions and functional calls.
4. Like OOP, functional programming languages support popular concepts such as
Abstraction, Encapsulation, Inheritance, and Polymorphism.

University Institute of Engineering 8


Object-Oriented Programming

The prime purpose of C++ programming was to add object orientation to the C
programming language, which is in itself one of the most powerful
programming languages.
The core of the pure object-oriented programming is to create an object, in
code, that has certain properties and methods. While designing C++ modules,
we try to see whole world in the form of objects.
For example a car is an object which has certain properties such as color,
number of doors, and the like. It also has certain methods such as accelerate,
brake, and so on.

University Institute of Engineering 9


Properties of Object-Oriented programming

1. Data as well as operations are encapsulated in objects


2. Information hiding is used to protect internal properties of an object
3. Objects interact by means of message passing.
4. In most object-oriented languages objects are grouped in classes
• Objects in classes are similar enough to allow programming of the classes, as
opposed to programming of the individual objects
• Classes represent concepts whereas objects represent phenomena
5. Classes are organized in inheritance hierarchies. Provides for class extension or
specialization

University Institute of Engineering 10


Logic Programming
Programs are written in the language of some logic.
Execution of a logic program is a theorem proving process; that is,
computation is done by logic inferences.
Prolog ( PROgramming in LOGic ) is a representative logic language

University Institute of Engineering 11


What is a logic

A logic is a language. It has syntax and semantics. More than a language,


it has inference rules.
Syntax: the rules about how to form formulas; this is usually the easy
part of a logic.

Semantics: about the meaning carried by the formulas, mainly in terms


of logical consequences.

Inference rules describe correct ways to derive conclusions.

University Institute of Engineering 12


Advantages of Logic Programming

i. Logic programming can be used to express knowledge in a way that


does not depend on the implementation, making programs more
flexible, compressed and understandable.
ii. It enables knowledge to be separated from use, ie the machine
architecture can be changed without changing programs or their
underlying code.
iii. It can be altered and extended in natural ways to support special forms
of knowledge, such as meta-level or higher-order knowledge.
iv. It can be used in non-computational disciplines relying on reasoning
and precise means of
expression.

University Institute of Engineering 12


References
i. https://www.computerhope.com/jargon/i/imp-programming.htm
ii. http://people.cs.aau.dk/paradigms_themes-paradigm-overview-
section.html
iii. https://www.tutorialspoint.com/functional_programming/functional_
programming_introduction.html
iv. http://www.doc.ic.ac.uk
Unit Course Outcomes

•Understand the various paradigms of computer programming


• Identify the strengths and weaknesses of different programming paradigms
I-III
•To provide in-depth knowledge of various concepts of programming
paradigms

Different Programming Paradigms Outcomes


•Understand the difference between various paradigms of computer
programming
• Identify the strengths and weaknesses of different programming paradigms

You might also like