SlideShare a Scribd company logo
Department of CSE-NEC 1
INTRODUCTION TO PROGRAMMING
(Common to All branches of Engineering)
Course Objectives:
• To introduce students to the fundamentals of computer programming.
• To provide hands-on experience with coding and debugging.
• To foster logical thinking and problem-solving skills using programming.
• To familiarize students with programming concepts such as data types, control structures,
functions, and arrays.
• To encourage collaborative learning and teamwork in coding projects
Course Outcomes: A student after completion of the course will be able to
CO1: Understand basics of computers, the concept of algorithm and algorithmic thinking.
CO2: Analyse a problem and develop an algorithm to solve it.
CO3: Implement various algorithms using the C programming language.
CO4: Understand more advanced features of C language.
CO5: Develop problem-solving skills and the ability to debug and optimize the code
Department of CSE-NEC 2
INTRODUCTION TO PROGRAMMING
(Common to All branches of Engineering)
UNIT I : Introduction to Programming and Problem Solving
History of Computers,
Basic organization of a computer: ALU, input-output units, memory, program counter,
 Introduction to Programming Languages,
Basics of a Computer Program: Algorithms, flowcharts, pseudo code.
Introduction to Compilation and Execution,
Primitive Data Types, Variables, and Constants,
Basic Input and Output, Operators, Type Conversion, and Casting.
Problem solving techniques: Algorithmic approach, characteristics of algorithm, Top-
down approach, Bottom-up approach, Time and space complexities of algorithms,
Department of CSE-NEC 3
Introduction to Computer Concepts:
Computer: It is an electronic device which can perform any computational tasks.
Computers makes our day to day activities much faster and easier.
General Functions :
 Input –Takes data from the input devices (Keyboard, Mouse).
 Process – Performs operations on the input data.
 Output – Produces the results using output devices (Monitor, Printer).
 Storage– Stores both the input data and output data in a storage device (Memory).
Department of CSE-NEC 4
Introduction to Computer Concepts:
Define Computer: Computer is a calculating machine, which accepts data through input
device, processes it using processing device and give the result through output device.
Computer is an electromechanical machine. It consists of electronic parts (IC’S) electrical
(motors, fan) and Mechanical parts (Outer cover, keyboard).
Characteristics of Computer:
The following are the characteristics of a computer:
1. Speed: Computer can process the data at an extremely high speed.
2. Accuracy: Computer will produce accurate result.
3. Reliability: It is the measurement of performance of computer
4. Versatile: Computer can be used for different purpose.
5. Storage capacity: computer can store large amount of data.
Department of CSE-NEC 5
History of computers can be understood by looking into five generations. With each new
generation of computers, there had been advancement in computer technology. The circuitry
became smaller with enhanced speed, less consumption of power, and efficient memory.
Therefore, each generation of computer is characterized by a major technological
development that has drastically changed the way in which computers operate.
History of Computers
Department of CSE-NEC 6
First Generation (1942–1955):
Hardware Technology: First generation computers were manufactured using thousands of
vacuum tubes. Vacuum tube is a device made of fragile glass.
Software Technology: Programming was done in machine language or assembly language.
Used for Scientific applications.
Examples: ENIAC, EDVAC, EDSAC, UNIVAC I, IBM 701
Highlights:
• They were the fastest calculating device of those times.
• Computers were too bulky and required a complete room for storage.
• Highly unreliable as vacuum tubes emitted a large amount of heat and burnt frequently.
• Required air-conditioned room for installation.
• Costly.
• Difficult to use.
• Required constant maintenance because vacuum tubes used filaments that had limited
lifetime.
Department of CSE-NEC 7
Second Generation (1955–1964):
Hardware Technology: Second generation computers were manufactured using
transistors Transistors were reliable, powerful, cheaper, smaller, and cooler than vacuum
tubes.
Software Technology: Programming was done in high level programming language.
Used for Scientific and commercial applications.
Examples: Honeywell 400, IBM 7030, CDC 1604, UNIVAC LARC
Highlights:
• Faster, smaller, cheaper, reliable, and easier to use than the first generation computers.
• Consumed 1/10th the power consumed by first generation computers
• Bulky in size and required a complete room for its installation.
• Dissipated less heat than first generation computers but still required air-conditioned
room.
• Costly.
• Difficult to use
Department of CSE-NEC 8
Third Generation (1964–1975):
Hardware Technology: Third generation computers were manufactured using integrated
chips (ICs) as shown in Figure 1.4. ICs consist of several components such as transistors,
capacitors, and resistors on a single chip to avoid wired interconnection between
components. These computers used SSI and MSI technology. Minicomputers came into
existence
Note: Initially, ICs contained 10–20 components. This technology was called Small Scale
Integration (SSI). Later it was enhanced to contain about 100 components. This was called
MSI (Medium Scale Integration).
Software Technology: Programming was done in high level programming language such as
FORTRAN, COBOL, Pascal, and BASIC
Used for Scientific, commercial, and interactive online applications.
Examples: IBM 360/370, PDP–8, PADP-11, CDC6600
Department of CSE-NEC 9
Highlights :
• Faster, smaller, cheaper, reliable, and easier to use than the second generation computers.
• They consumed less power than second generation computers.
• Bulky in size and required a complete room for its installation.
• Dissipated less heat than second generation computers but still required air-conditioned
room.
• Costly.
• Easier to use and upgrade
Department of CSE-NEC 10
Fourth Generation (1975–1989):
Hardware Technology: Fourth generation computers were manufactured using ICs with
LSI (Large Scale Integrated) and later with VLSI (Very Large Scale Integrated) technology
as shown in Figure 1.5. Microcomputers came into existence, and use of personal computers
became widespread during this period. High speed computer networks in the form of LANs,
WANs, and MANs started growing. Besides mainframes, supercomputers were also used.
Note: LSI contained 30,000 components on a single chip and VLSI technology had about 1
million electronic components on a single chip.
Software Technology: Programming was done in high level programming language like C,
C++. Graphical user interface (GUI) based operating system (like Windows) was
introduced. It had icons and menus among other features to allow computers to be used as a
general purpose machine by all users.
Department of CSE-NEC 11
Used for Scientific, commercial, interactive online, and network applications.
Examples: IBM PC, Apple II, TRS–80, VAX 9000, CRAY–1, CRAY–2, CRAY–X/MP
Highlights Faster, smaller, cheaper, powerful, reliable, and easier to use than the previous
generation computers.
Department of CSE-NEC 12
Fifth Generation (1989–Present):
Hardware Technology: Fifth generation computers were manufactured using ICs with ULSI
(Ultra Large Scale Integrated) technology as shown in Figure 1.6. Use of Internet became
widespread. Very powerful mainframes, desktops, portable laptops, smartphones are being
used commonly. Super computers use parallel processing techniques.
Note : ULSI contained about 10 million electronic components on a single chip.
Software Technology : Programming was done in high level
programming language such as Java, Python, C#.
Used for Scientific, commercial, interactive online, multimedia
(graphics, audio, video), and network applications.
Examples: IBM notebooks, Pentium PCs, SUM workstations,
IBM SP/2, Param supercomputer.
Department of CSE-NEC 13
Highlights :
• Faster, smaller, cheaper, powerful, reliable, and easier to use than the previous generation
computers.
• Speed of microprocessors and the size of memory are growing rapidly.
• High-end features available on mainframe computers in the fourth generation are now
available on the microprocessors.
• Consume less power than computers of prior generations.
• Air-conditioned rooms required for mainframes and supercomputers but not for
microprocessors.
Department of CSE-NEC 14
Any programming language is implemented on a computer. Right from its inception, to the
present day, all computer system (irrespective of their shape & size) perform the following 5
basic operations.
It converts the raw input data into information, which is useful to the users.
Inputting: It is the process of entering data & instructions to the computer system.
Storing: The data & instructions are stored for either initial or additional processing, as &
when required.
Processing: It requires performing arithmetic or logical operation on the saved data to
convert it into useful information.
Outputting: It is the process of producing the output data to the end user.
Controlling: The above operations have to be directed in a particular sequence to be
completed.
Basic organization of a computer:
Department of CSE-NEC 15
Block Diagram of a Computer
Department of CSE-NEC 16
The Input Unit
The input unit is the platform from where the raw data is passed into
the computer system. The input can be in any form. For example, the
mouse-clicked input, button-input, keyboard-input, etc. All the input
data is passed from the input unit to the computer’s storage unit.
Department of CSE-NEC 17
Central Processing Unit (CPU)
The CPU is the primary component that processes the input passed
into the computer. It is also called the heart or brain of the computer
without the CPU you just have the useless desktop. The CPU has
three components Arithmetic Logical Unit (ALU) ,Control Unit
(CU) and Memory Unit(MU).
Department of CSE-NEC 18
Arithmetic Logical Unit (ALU)
We all know that computer understands the language of the binary
numbers that is 0 and the 1. The Arithmetic Logical Unit (ALU) is the
digital circuit that takes these 0s and 1s and performs the necessary
arithmetic operations on it and releases the results as the output
asynchronously.
Control Unit
The Control Unit (CU) is like the traffic guy. It controls the
instructions flowing in and out of the CPU. The CU is smart enough
to sense that when the CPU’s central processor needs data and when
not. If the data is required then it retrieves it from the Storage Unit
and transfers it into the CPU. The CU converts the data into signals
and passes it into the central processor.
Department of CSE-NEC 19
Storage Unit - Primary and the Secondary Unit
The raw data from the Input unit is saved in the Storage Unit. It is the place
where the data that is to be processed and processed data is stored. The
Storage Unit is further classified into two parts.
•Primary Storage
•Secondary Storage
Primary Storage
This storage is also known as the main memory of the computer system.
This part of the storage unit holds the data, programs, and instructions that
are currently in use. This storage part resides in the motherboard. Primary
storage contains the ROM and RAM of the computer system.
Department of CSE-NEC 20
Secondary Storage
It is a non-volatile and permanent data storage device. It is the place where the data is
stored for a short or a long time. The secondary storage supports the primary storage.
This device is also known as the hard drive of the computer. It is primarily used as a
backup device.
Output Unit
The output unit is the place through which the computer system outputs the data.
The output unit is always hardware. The computer screen, speakers, printer, etc.
are the output devices because from these devices users get their processed data.
Department of CSE-NEC 21
Classification of Computers:
Department of CSE-NEC 22
COMPUTER LANGUAGES
Computer languages are broadly classified as:
1.Low Level Language: The term low level highlights the fact that it is closer to a language
which the machine understands.
-Machine Language i.e in the form of 0’s and 1’s, called binary numbers
-Assembly Language i.e symbolic codes (called mnemonics)
2.High Level Language: Low level language requires extensive knowledge of the hardware
since it is machine dependent. To overcome this limitation, high level language has been
evolved which uses normal English, which is easy to understand to solve any problem. High
level languages are computer independent and programming becomes quite easy and simple
- BASIC (Beginners All Purpose Symbolic Instruction Code)
-COBOL (Common Business Oriented language)
- FORTRAN (Formula Translation)
-C
-C++
Department of CSE-NEC 23
Machine Language: It is the lowest and most elementary level of Programming language
and was the first type of programming language to be Developed. Machine Language is
basically the only language which computer Can understand. In fact, a manufacturer designs a
computer to obey just one Language, its machine code, which is represented inside the
computer by a String of binary digits (bits) 0 and 1. The symbol 0 stands for the absence of
Electric pulse and 1 for the
Assembly Language: It was developed to overcome some of the many inconveniences of
machine language. This is another low level but a very important language in which
operation codes and operands are given in the form of alphanumeric symbols instead of 0 s
‟
and l s. These alphanumeric symbols will be known as mnemonic codes and can have
‟
maximum up to 5 letter combination e.g. ADD for addition, SUB for subtraction,
START,LABEL etc. Because of this feature it is also known as „Symbolic Programming
Language . This language is also very difficult and needs a lot of practice to master it
‟
because very small
Department of CSE-NEC 24
Department of CSE-NEC 25
BASIC (Beginners All Purpose Symbolic Instruction Code): It is widely used, easy to
learn general purpose language. Mainly used in microcomputers in earlier days.
COBOL (Common Business Oriented language): A standardized language used for
commercial applications.
FORTRAN (Formula Translation): Developed for solving mathematical and scientific
problems. One of the most popular languages among scientific community.
C: Structured Programming Language used for all purpose such as scientific application,
commercial application, developing games etc.
C++: Popular object oriented programming language, used for general purpose.
Department of CSE-NEC 26
Machine Level Language (MLL) : Binary language it use 1 and 0. It is the only language
understood by the computer.
Assembly Level Language (ALL) : It uses short notations like add, sub, mul and div etc. It
cannot be understood by the computer. Hence ALL needs to be converted into MLL
Assembler: is the program, which converts ALL to MLL and vice versa.
Example for ALL: ALL 8085, ALL 8086
High Level Language (HLL) : It is English like language. It is easy to understand by the
programmer.
It cannot be understood by the computer.
HLL needs to be converted into MLL.
Compiler or Interpreter will be used to convert HLL to MLL and vice versa.
Compiler: converts HLL to MLL in one step.
Interpreter: Converts HLL to MLL line by line.
Example: C,C++, Java
Department of CSE-NEC 27
Algorithm: An algorithm is a description of a procedure which terminates with a
result. Algorithm is a step-by-step method of solving a problem.
Properties of an Algorithm:
1) Finiteness: - An algorithm terminates after a finite numbers of steps.
2) Definiteness: - Each step in algorithm is unambiguous. This means that the
action specified by the step cannot be interpreted (explain the meaning of) in
multiple ways & can be performed without any confusion.
3) Input: - An algorithm accepts zero or more inputs
4) Output:- An algorithm should produce at least one output.
5) Effectiveness: - It consists of basic instructions that are realizable. This means
that the instructions can be performed by using the given inputs in a finite amount
of time.
6) Generality: An algorithm must be general, meaning that it can be applied to a
wide range of problems rather than being specific to a single problem.
Department of CSE-NEC 28
Example: - The sum of two integers.
Step 1 - Get started
Step 2 - Declare three integers a, b, c
Step 3 - Define the values of a and b
Step 4 - Add the values of a and b
Step 5 - Save the output of step 4 in c
Step 6 - Print c
Algorithm to find whether a number even or odd:
Step1: START
Step2: Take a number
Step3: if the number is divisible by2 then
print that number is even
otherwise print that number is odd
Step4: End
Department of CSE-NEC 29
Department of CSE-NEC 30
Algorithm Complexity
• Algorithmic complexity is a measure to measure the efficiency
and performance of the algorithm. Algorithms are usually
evaluated in terms of the time and space required to solve a
problem or achieve a specific goal.
Two factors are used in the complexity of the algorithem
• Time Complexity.
• Space Complexity.
Department of CSE-NEC 31
Time Complexity:
•The amount of time an algorithm needs to do a task is referred to as time
complexity. It is usually measured by the number of operations or steps an
algorithm must perform to solve a problem.
•The time complexity of an algorithm is important because it determines how long
it takes to execute and can have a significant impact on program and system
performance.
•The time complexity of an algorithm can be expressed using Big O notation, a
way of expressing an upper bound on the time complexity of an algorithm.
•An algorithm with time complexity O(n) means that the time required to run the
algorithm is directly proportional to the size of the input data (n).
•Other common time complexities are O(n^2) quadratic complexity and O(log n)
logarithmic complexity.
Department of CSE-NEC 32
Space Complexity
•On the other hand, space complexity refers to the amount of memory
or storage space required to execute the algorithm.
•This is important because it determines the number of resources
required to run algorithms that can affect the overall performance of
your application or system.
•If the space complexity of the algorithm is O(n), it uses an amount of
memory that grows linearly with the size of the input.
•If the algorithm has O(1) space complexity, it uses a fixed amount of
memory regardless of the size of the input.
Department of CSE-NEC 33
Department of CSE-NEC 34
FLOW CHART
• The pictorial representation of algorithm is called flowchart.
Uses of flow chart:
1 : flow chart helps to understand the program easily.
2 : as different symbols are used to specify the type of operation
performed, it is easier to understand the complex programs with
the help of flowcharts.
Department of CSE-NEC 35
Department of CSE-NEC 36
Algorithm Pseudocode
An Algorithm is used to provide a solution to a
particular problem in form of a well-defined
step-based form.
A Pseudocode is a step-by-step description of an
algorithm in code-like structure using plain
English text.
An algorithm only uses simple English words
Pseudocode also uses reserved keywords like if-
else, for, while, etc.
These are a sequence of steps of a solution to a
problem
These are fake codes as the word pseudo means
fake, using code like structure and plain English
text
There are no rules to writing algorithms There are certain rules for writing pseudocode
Algorithms can be considered pseudocode Pseudocode cannot be considered an algorithm
It is difficult to understand and interpret It is easy to understand and interpret
Department of CSE-NEC 37
Problem solving Strategies
• Top-Down Approach is an approach to design algorithms in
which a bigger problem is broken down into smaller parts.
Thus, it uses the decomposition approach. This approach is
generally used by structured programming languages such as
C, COBOL, FORTRAN.
• Bottom-Up Approach is one in which the smaller problems
are solved, and then these solved problems are integrated to
find the solution to a bigger problem. Therefore, it uses
composition approach. It is generally used with object oriented
programming paradigm such as C++, Java, and Python.
Department of CSE-NEC 38
S.No. Top-Down Approach Bottom-Up Approach
1.
In this approach, the
problem is broken down
into smaller parts.
In this approach, the
smaller problems are
solved.
2.
It is generally used by
structured programming
languages such as C,
COBOL, FORTRAN, etc.
It is generally used with
object oriented
programming paradigm
such as C++, Java,
Python, etc.
3.
It is generally used with
documentation of module
and debugging code.
It is generally used in
testing modules.
4.
It does not require
communication between
modules.
It requires relatively more
communication between
modules.
5.
It contains redundant
information.
It does not contain
redundant information.
6.
Decomposition approach
is used here.
Composition approach is
used here.
7.
The implementation
depends on the
programming language
and platform.
Data encapsulation and
data hiding is
implemented in this
approach.
Department of CSE-NEC 39
Department of CSE-NEC 40
Department of CSE-NEC 41
Department of CSE-NEC 42
Department of CSE-NEC 43
Compilation Process in C
• What is a compilation?
The compilation is a process of converting the source code into object
code or machine code. It is done with the help of the compiler. The
compiler checks the source code for the syntactical or structural errors,
and if the source code is error-free, then it generates the object code.
The compilation process can be divided into four steps,
• Pre-processing
• Compiling,
• Assembling,
• Linking
Department of CSE-NEC 44
Pre-processing
The pre-processor takes the source code as an input, This phase includes:
• Removal of Comments
• Expansion of Macros
• Expansion of the included files.
The source code is the code which is written in a text editor and the source
code file is given an extension filename.c. This source code is first passed to
the pre-processor, and then the pre-processor expands this code. After
expanding the code, the expanded code is passed to the compiler. The pre-
processed output is stored in the filename.i
• Compiling
The code which is expanded by the pre-processor(filename.i) is passed to the
compiler. The compiler converts this code into assembly code. Or we can say
that the C compiler converts the pre-processed code into assembly code. The
compiler phase output is stored in the filename.s
Department of CSE-NEC 45
• Assembling: The assembly code is converted into object code by using an
assembler.
• In this phase the filename.s is taken as input and turned into filename.o by the
assembler. This file contains machine-level instructions. At this phase, only
existing code is converted into machine language, and the function calls like
printf() are not resolved.
• Linking: Mainly, all the programs written in C use library functions. These
library functions are pre-compiled, and the object code of these library files is
stored with '.lib' (or '.a') extension. The main working of the linker is to
combine the object code of library files with the object code of our program.
• Loading: linker creates the executable file(filename.exe). The loader will then
load the executable file for the execution.
Department of CSE-NEC 46
Department of CSE-NEC 47
Constant Example
Decimal Constant 10, 20, 450 etc.
Real or Floating-point
Constant
10.3, 20.2, 450.6 etc.
Octal Constant 021, 033, 046 etc.
Hexadecimal Constant 0x2a, 0x7b, 0xaa etc.
Character Constant 'a', 'b', 'x' etc.
String Constant "c", "c program", "c in
javatpoint" etc.
68ul —> Unsigned Long Integer Constant
50l —> Long Integer Constant
30u —> Unsigned Integer Constant
Department of CSE-NEC 48
#include<stdio.h>
#include<conio.h>
void main()
{
int q = 9 ;
const int a = 10 ;
q = 15 ;
a = 100 ; // creates an error
printf(“q = %dna = %d”, q, a ) ;
}
#include<stdio.h>
#include<conio.h>
#define PI 3.14
void main()
{
int a, area ;
printf(“Enter the radius of the given
circle here : “) ;
scanf(“%d”, &a) ;
area = PI * (a * a) ;
printf(“The area of the circle is = %d”,
area) ;
}

More Related Content

Similar to CP means computer programming in b tech first year (20)

PDF
Introduction to Computer.pdf
PinkiNayak1
 
DOCX
Information technology
Manoj Soni
 
PPTX
connect hardware perioheral---------LO1.pptx
tesfayeamare534
 
PPTX
ITM Mod 1 intrduction and short key will help to know
jaya315652
 
PPTX
computer application in management ch1234.pptx
ArebuMaruf
 
PPTX
Unit 1.pptx
AshwiniMate10
 
PDF
Week 1 intro to computer organization and assembly language
AdeelAsghar36
 
PPT
Unit 1 one part introduction to computers
Neha Kurale
 
PPT
CS465Lec1.ppt computer architecture in the fall term
ppavani10
 
PPTX
IS 139 Lecture 1 - 2015
Aron Kondoro
 
PDF
Presentation on Computer Basics and architecture.pdf
navikvel
 
PPTX
Generation of computers
PriyaU5
 
PPTX
computer applicationin hospitality Industry1 periyar university unit1
admin information
 
PPTX
computer application in hospitality Industry, periyar university unit 1
admin information
 
PPTX
Unit I
admin information
 
PPTX
Unit i
admin information
 
PPTX
Unit i
admin information
 
DOCX
M1- IT Tools & Application.docx
ssuser3940ac
 
PPTX
Essentials of Computer Science Engineering.pptx
HPBackup2
 
PPTX
Fundamentals of computers & information system
shefali mishra
 
Introduction to Computer.pdf
PinkiNayak1
 
Information technology
Manoj Soni
 
connect hardware perioheral---------LO1.pptx
tesfayeamare534
 
ITM Mod 1 intrduction and short key will help to know
jaya315652
 
computer application in management ch1234.pptx
ArebuMaruf
 
Unit 1.pptx
AshwiniMate10
 
Week 1 intro to computer organization and assembly language
AdeelAsghar36
 
Unit 1 one part introduction to computers
Neha Kurale
 
CS465Lec1.ppt computer architecture in the fall term
ppavani10
 
IS 139 Lecture 1 - 2015
Aron Kondoro
 
Presentation on Computer Basics and architecture.pdf
navikvel
 
Generation of computers
PriyaU5
 
computer applicationin hospitality Industry1 periyar university unit1
admin information
 
computer application in hospitality Industry, periyar university unit 1
admin information
 
M1- IT Tools & Application.docx
ssuser3940ac
 
Essentials of Computer Science Engineering.pptx
HPBackup2
 
Fundamentals of computers & information system
shefali mishra
 

Recently uploaded (20)

PPTX
Optimizing Cancer Screening With MCED Technologies: From Science to Practical...
i3 Health
 
PPSX
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
PPSX
Health Planning in india - Unit 03 - CHN 2 - GNM 3RD YEAR.ppsx
Priyanshu Anand
 
PPTX
How to Define Translation to Custom Module And Add a new language in Odoo 18
Celine George
 
PPTX
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
PDF
Zoology (Animal Physiology) practical Manual
raviralanaresh2
 
PPTX
PPT on the Development of Education in the Victorian England
Beena E S
 
PPTX
How to Manage Promotions in Odoo 18 Sales
Celine George
 
PPTX
Optimizing Cancer Screening With MCED Technologies: From Science to Practical...
i3 Health
 
PPTX
Views on Education of Indian Thinkers J.Krishnamurthy..pptx
ShrutiMahanta1
 
PDF
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
PPTX
Presentation: Climate Citizenship Digital Education
Karl Donert
 
PDF
Federal dollars withheld by district, charter, grant recipient
Mebane Rash
 
PPTX
CONVULSIVE DISORDERS: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
PPTX
How to Manage Access Rights & User Types in Odoo 18
Celine George
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PDF
IMP NAAC-Reforms-Stakeholder-Consultation-Presentation-on-Draft-Metrics-Unive...
BHARTIWADEKAR
 
PDF
1, 2, 3… E MAIS UM CICLO CHEGA AO FIM!.pdf
Colégio Santa Teresinha
 
PPTX
How to Configure Access Rights of Manufacturing Orders in Odoo 18 Manufacturing
Celine George
 
PDF
BÀI TẬP BỔ TRỢ THEO LESSON TIẾNG ANH - I-LEARN SMART WORLD 7 - CẢ NĂM - CÓ ĐÁ...
Nguyen Thanh Tu Collection
 
Optimizing Cancer Screening With MCED Technologies: From Science to Practical...
i3 Health
 
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
Health Planning in india - Unit 03 - CHN 2 - GNM 3RD YEAR.ppsx
Priyanshu Anand
 
How to Define Translation to Custom Module And Add a new language in Odoo 18
Celine George
 
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
Zoology (Animal Physiology) practical Manual
raviralanaresh2
 
PPT on the Development of Education in the Victorian England
Beena E S
 
How to Manage Promotions in Odoo 18 Sales
Celine George
 
Optimizing Cancer Screening With MCED Technologies: From Science to Practical...
i3 Health
 
Views on Education of Indian Thinkers J.Krishnamurthy..pptx
ShrutiMahanta1
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
Presentation: Climate Citizenship Digital Education
Karl Donert
 
Federal dollars withheld by district, charter, grant recipient
Mebane Rash
 
CONVULSIVE DISORDERS: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
How to Manage Access Rights & User Types in Odoo 18
Celine George
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
IMP NAAC-Reforms-Stakeholder-Consultation-Presentation-on-Draft-Metrics-Unive...
BHARTIWADEKAR
 
1, 2, 3… E MAIS UM CICLO CHEGA AO FIM!.pdf
Colégio Santa Teresinha
 
How to Configure Access Rights of Manufacturing Orders in Odoo 18 Manufacturing
Celine George
 
BÀI TẬP BỔ TRỢ THEO LESSON TIẾNG ANH - I-LEARN SMART WORLD 7 - CẢ NĂM - CÓ ĐÁ...
Nguyen Thanh Tu Collection
 
Ad

CP means computer programming in b tech first year

  • 1. Department of CSE-NEC 1 INTRODUCTION TO PROGRAMMING (Common to All branches of Engineering) Course Objectives: • To introduce students to the fundamentals of computer programming. • To provide hands-on experience with coding and debugging. • To foster logical thinking and problem-solving skills using programming. • To familiarize students with programming concepts such as data types, control structures, functions, and arrays. • To encourage collaborative learning and teamwork in coding projects Course Outcomes: A student after completion of the course will be able to CO1: Understand basics of computers, the concept of algorithm and algorithmic thinking. CO2: Analyse a problem and develop an algorithm to solve it. CO3: Implement various algorithms using the C programming language. CO4: Understand more advanced features of C language. CO5: Develop problem-solving skills and the ability to debug and optimize the code
  • 2. Department of CSE-NEC 2 INTRODUCTION TO PROGRAMMING (Common to All branches of Engineering) UNIT I : Introduction to Programming and Problem Solving History of Computers, Basic organization of a computer: ALU, input-output units, memory, program counter,  Introduction to Programming Languages, Basics of a Computer Program: Algorithms, flowcharts, pseudo code. Introduction to Compilation and Execution, Primitive Data Types, Variables, and Constants, Basic Input and Output, Operators, Type Conversion, and Casting. Problem solving techniques: Algorithmic approach, characteristics of algorithm, Top- down approach, Bottom-up approach, Time and space complexities of algorithms,
  • 3. Department of CSE-NEC 3 Introduction to Computer Concepts: Computer: It is an electronic device which can perform any computational tasks. Computers makes our day to day activities much faster and easier. General Functions :  Input –Takes data from the input devices (Keyboard, Mouse).  Process – Performs operations on the input data.  Output – Produces the results using output devices (Monitor, Printer).  Storage– Stores both the input data and output data in a storage device (Memory).
  • 4. Department of CSE-NEC 4 Introduction to Computer Concepts: Define Computer: Computer is a calculating machine, which accepts data through input device, processes it using processing device and give the result through output device. Computer is an electromechanical machine. It consists of electronic parts (IC’S) electrical (motors, fan) and Mechanical parts (Outer cover, keyboard). Characteristics of Computer: The following are the characteristics of a computer: 1. Speed: Computer can process the data at an extremely high speed. 2. Accuracy: Computer will produce accurate result. 3. Reliability: It is the measurement of performance of computer 4. Versatile: Computer can be used for different purpose. 5. Storage capacity: computer can store large amount of data.
  • 5. Department of CSE-NEC 5 History of computers can be understood by looking into five generations. With each new generation of computers, there had been advancement in computer technology. The circuitry became smaller with enhanced speed, less consumption of power, and efficient memory. Therefore, each generation of computer is characterized by a major technological development that has drastically changed the way in which computers operate. History of Computers
  • 6. Department of CSE-NEC 6 First Generation (1942–1955): Hardware Technology: First generation computers were manufactured using thousands of vacuum tubes. Vacuum tube is a device made of fragile glass. Software Technology: Programming was done in machine language or assembly language. Used for Scientific applications. Examples: ENIAC, EDVAC, EDSAC, UNIVAC I, IBM 701 Highlights: • They were the fastest calculating device of those times. • Computers were too bulky and required a complete room for storage. • Highly unreliable as vacuum tubes emitted a large amount of heat and burnt frequently. • Required air-conditioned room for installation. • Costly. • Difficult to use. • Required constant maintenance because vacuum tubes used filaments that had limited lifetime.
  • 7. Department of CSE-NEC 7 Second Generation (1955–1964): Hardware Technology: Second generation computers were manufactured using transistors Transistors were reliable, powerful, cheaper, smaller, and cooler than vacuum tubes. Software Technology: Programming was done in high level programming language. Used for Scientific and commercial applications. Examples: Honeywell 400, IBM 7030, CDC 1604, UNIVAC LARC Highlights: • Faster, smaller, cheaper, reliable, and easier to use than the first generation computers. • Consumed 1/10th the power consumed by first generation computers • Bulky in size and required a complete room for its installation. • Dissipated less heat than first generation computers but still required air-conditioned room. • Costly. • Difficult to use
  • 8. Department of CSE-NEC 8 Third Generation (1964–1975): Hardware Technology: Third generation computers were manufactured using integrated chips (ICs) as shown in Figure 1.4. ICs consist of several components such as transistors, capacitors, and resistors on a single chip to avoid wired interconnection between components. These computers used SSI and MSI technology. Minicomputers came into existence Note: Initially, ICs contained 10–20 components. This technology was called Small Scale Integration (SSI). Later it was enhanced to contain about 100 components. This was called MSI (Medium Scale Integration). Software Technology: Programming was done in high level programming language such as FORTRAN, COBOL, Pascal, and BASIC Used for Scientific, commercial, and interactive online applications. Examples: IBM 360/370, PDP–8, PADP-11, CDC6600
  • 9. Department of CSE-NEC 9 Highlights : • Faster, smaller, cheaper, reliable, and easier to use than the second generation computers. • They consumed less power than second generation computers. • Bulky in size and required a complete room for its installation. • Dissipated less heat than second generation computers but still required air-conditioned room. • Costly. • Easier to use and upgrade
  • 10. Department of CSE-NEC 10 Fourth Generation (1975–1989): Hardware Technology: Fourth generation computers were manufactured using ICs with LSI (Large Scale Integrated) and later with VLSI (Very Large Scale Integrated) technology as shown in Figure 1.5. Microcomputers came into existence, and use of personal computers became widespread during this period. High speed computer networks in the form of LANs, WANs, and MANs started growing. Besides mainframes, supercomputers were also used. Note: LSI contained 30,000 components on a single chip and VLSI technology had about 1 million electronic components on a single chip. Software Technology: Programming was done in high level programming language like C, C++. Graphical user interface (GUI) based operating system (like Windows) was introduced. It had icons and menus among other features to allow computers to be used as a general purpose machine by all users.
  • 11. Department of CSE-NEC 11 Used for Scientific, commercial, interactive online, and network applications. Examples: IBM PC, Apple II, TRS–80, VAX 9000, CRAY–1, CRAY–2, CRAY–X/MP Highlights Faster, smaller, cheaper, powerful, reliable, and easier to use than the previous generation computers.
  • 12. Department of CSE-NEC 12 Fifth Generation (1989–Present): Hardware Technology: Fifth generation computers were manufactured using ICs with ULSI (Ultra Large Scale Integrated) technology as shown in Figure 1.6. Use of Internet became widespread. Very powerful mainframes, desktops, portable laptops, smartphones are being used commonly. Super computers use parallel processing techniques. Note : ULSI contained about 10 million electronic components on a single chip. Software Technology : Programming was done in high level programming language such as Java, Python, C#. Used for Scientific, commercial, interactive online, multimedia (graphics, audio, video), and network applications. Examples: IBM notebooks, Pentium PCs, SUM workstations, IBM SP/2, Param supercomputer.
  • 13. Department of CSE-NEC 13 Highlights : • Faster, smaller, cheaper, powerful, reliable, and easier to use than the previous generation computers. • Speed of microprocessors and the size of memory are growing rapidly. • High-end features available on mainframe computers in the fourth generation are now available on the microprocessors. • Consume less power than computers of prior generations. • Air-conditioned rooms required for mainframes and supercomputers but not for microprocessors.
  • 14. Department of CSE-NEC 14 Any programming language is implemented on a computer. Right from its inception, to the present day, all computer system (irrespective of their shape & size) perform the following 5 basic operations. It converts the raw input data into information, which is useful to the users. Inputting: It is the process of entering data & instructions to the computer system. Storing: The data & instructions are stored for either initial or additional processing, as & when required. Processing: It requires performing arithmetic or logical operation on the saved data to convert it into useful information. Outputting: It is the process of producing the output data to the end user. Controlling: The above operations have to be directed in a particular sequence to be completed. Basic organization of a computer:
  • 15. Department of CSE-NEC 15 Block Diagram of a Computer
  • 16. Department of CSE-NEC 16 The Input Unit The input unit is the platform from where the raw data is passed into the computer system. The input can be in any form. For example, the mouse-clicked input, button-input, keyboard-input, etc. All the input data is passed from the input unit to the computer’s storage unit.
  • 17. Department of CSE-NEC 17 Central Processing Unit (CPU) The CPU is the primary component that processes the input passed into the computer. It is also called the heart or brain of the computer without the CPU you just have the useless desktop. The CPU has three components Arithmetic Logical Unit (ALU) ,Control Unit (CU) and Memory Unit(MU).
  • 18. Department of CSE-NEC 18 Arithmetic Logical Unit (ALU) We all know that computer understands the language of the binary numbers that is 0 and the 1. The Arithmetic Logical Unit (ALU) is the digital circuit that takes these 0s and 1s and performs the necessary arithmetic operations on it and releases the results as the output asynchronously. Control Unit The Control Unit (CU) is like the traffic guy. It controls the instructions flowing in and out of the CPU. The CU is smart enough to sense that when the CPU’s central processor needs data and when not. If the data is required then it retrieves it from the Storage Unit and transfers it into the CPU. The CU converts the data into signals and passes it into the central processor.
  • 19. Department of CSE-NEC 19 Storage Unit - Primary and the Secondary Unit The raw data from the Input unit is saved in the Storage Unit. It is the place where the data that is to be processed and processed data is stored. The Storage Unit is further classified into two parts. •Primary Storage •Secondary Storage Primary Storage This storage is also known as the main memory of the computer system. This part of the storage unit holds the data, programs, and instructions that are currently in use. This storage part resides in the motherboard. Primary storage contains the ROM and RAM of the computer system.
  • 20. Department of CSE-NEC 20 Secondary Storage It is a non-volatile and permanent data storage device. It is the place where the data is stored for a short or a long time. The secondary storage supports the primary storage. This device is also known as the hard drive of the computer. It is primarily used as a backup device. Output Unit The output unit is the place through which the computer system outputs the data. The output unit is always hardware. The computer screen, speakers, printer, etc. are the output devices because from these devices users get their processed data.
  • 21. Department of CSE-NEC 21 Classification of Computers:
  • 22. Department of CSE-NEC 22 COMPUTER LANGUAGES Computer languages are broadly classified as: 1.Low Level Language: The term low level highlights the fact that it is closer to a language which the machine understands. -Machine Language i.e in the form of 0’s and 1’s, called binary numbers -Assembly Language i.e symbolic codes (called mnemonics) 2.High Level Language: Low level language requires extensive knowledge of the hardware since it is machine dependent. To overcome this limitation, high level language has been evolved which uses normal English, which is easy to understand to solve any problem. High level languages are computer independent and programming becomes quite easy and simple - BASIC (Beginners All Purpose Symbolic Instruction Code) -COBOL (Common Business Oriented language) - FORTRAN (Formula Translation) -C -C++
  • 23. Department of CSE-NEC 23 Machine Language: It is the lowest and most elementary level of Programming language and was the first type of programming language to be Developed. Machine Language is basically the only language which computer Can understand. In fact, a manufacturer designs a computer to obey just one Language, its machine code, which is represented inside the computer by a String of binary digits (bits) 0 and 1. The symbol 0 stands for the absence of Electric pulse and 1 for the Assembly Language: It was developed to overcome some of the many inconveniences of machine language. This is another low level but a very important language in which operation codes and operands are given in the form of alphanumeric symbols instead of 0 s ‟ and l s. These alphanumeric symbols will be known as mnemonic codes and can have ‟ maximum up to 5 letter combination e.g. ADD for addition, SUB for subtraction, START,LABEL etc. Because of this feature it is also known as „Symbolic Programming Language . This language is also very difficult and needs a lot of practice to master it ‟ because very small
  • 25. Department of CSE-NEC 25 BASIC (Beginners All Purpose Symbolic Instruction Code): It is widely used, easy to learn general purpose language. Mainly used in microcomputers in earlier days. COBOL (Common Business Oriented language): A standardized language used for commercial applications. FORTRAN (Formula Translation): Developed for solving mathematical and scientific problems. One of the most popular languages among scientific community. C: Structured Programming Language used for all purpose such as scientific application, commercial application, developing games etc. C++: Popular object oriented programming language, used for general purpose.
  • 26. Department of CSE-NEC 26 Machine Level Language (MLL) : Binary language it use 1 and 0. It is the only language understood by the computer. Assembly Level Language (ALL) : It uses short notations like add, sub, mul and div etc. It cannot be understood by the computer. Hence ALL needs to be converted into MLL Assembler: is the program, which converts ALL to MLL and vice versa. Example for ALL: ALL 8085, ALL 8086 High Level Language (HLL) : It is English like language. It is easy to understand by the programmer. It cannot be understood by the computer. HLL needs to be converted into MLL. Compiler or Interpreter will be used to convert HLL to MLL and vice versa. Compiler: converts HLL to MLL in one step. Interpreter: Converts HLL to MLL line by line. Example: C,C++, Java
  • 27. Department of CSE-NEC 27 Algorithm: An algorithm is a description of a procedure which terminates with a result. Algorithm is a step-by-step method of solving a problem. Properties of an Algorithm: 1) Finiteness: - An algorithm terminates after a finite numbers of steps. 2) Definiteness: - Each step in algorithm is unambiguous. This means that the action specified by the step cannot be interpreted (explain the meaning of) in multiple ways & can be performed without any confusion. 3) Input: - An algorithm accepts zero or more inputs 4) Output:- An algorithm should produce at least one output. 5) Effectiveness: - It consists of basic instructions that are realizable. This means that the instructions can be performed by using the given inputs in a finite amount of time. 6) Generality: An algorithm must be general, meaning that it can be applied to a wide range of problems rather than being specific to a single problem.
  • 28. Department of CSE-NEC 28 Example: - The sum of two integers. Step 1 - Get started Step 2 - Declare three integers a, b, c Step 3 - Define the values of a and b Step 4 - Add the values of a and b Step 5 - Save the output of step 4 in c Step 6 - Print c Algorithm to find whether a number even or odd: Step1: START Step2: Take a number Step3: if the number is divisible by2 then print that number is even otherwise print that number is odd Step4: End
  • 30. Department of CSE-NEC 30 Algorithm Complexity • Algorithmic complexity is a measure to measure the efficiency and performance of the algorithm. Algorithms are usually evaluated in terms of the time and space required to solve a problem or achieve a specific goal. Two factors are used in the complexity of the algorithem • Time Complexity. • Space Complexity.
  • 31. Department of CSE-NEC 31 Time Complexity: •The amount of time an algorithm needs to do a task is referred to as time complexity. It is usually measured by the number of operations or steps an algorithm must perform to solve a problem. •The time complexity of an algorithm is important because it determines how long it takes to execute and can have a significant impact on program and system performance. •The time complexity of an algorithm can be expressed using Big O notation, a way of expressing an upper bound on the time complexity of an algorithm. •An algorithm with time complexity O(n) means that the time required to run the algorithm is directly proportional to the size of the input data (n). •Other common time complexities are O(n^2) quadratic complexity and O(log n) logarithmic complexity.
  • 32. Department of CSE-NEC 32 Space Complexity •On the other hand, space complexity refers to the amount of memory or storage space required to execute the algorithm. •This is important because it determines the number of resources required to run algorithms that can affect the overall performance of your application or system. •If the space complexity of the algorithm is O(n), it uses an amount of memory that grows linearly with the size of the input. •If the algorithm has O(1) space complexity, it uses a fixed amount of memory regardless of the size of the input.
  • 34. Department of CSE-NEC 34 FLOW CHART • The pictorial representation of algorithm is called flowchart. Uses of flow chart: 1 : flow chart helps to understand the program easily. 2 : as different symbols are used to specify the type of operation performed, it is easier to understand the complex programs with the help of flowcharts.
  • 36. Department of CSE-NEC 36 Algorithm Pseudocode An Algorithm is used to provide a solution to a particular problem in form of a well-defined step-based form. A Pseudocode is a step-by-step description of an algorithm in code-like structure using plain English text. An algorithm only uses simple English words Pseudocode also uses reserved keywords like if- else, for, while, etc. These are a sequence of steps of a solution to a problem These are fake codes as the word pseudo means fake, using code like structure and plain English text There are no rules to writing algorithms There are certain rules for writing pseudocode Algorithms can be considered pseudocode Pseudocode cannot be considered an algorithm It is difficult to understand and interpret It is easy to understand and interpret
  • 37. Department of CSE-NEC 37 Problem solving Strategies • Top-Down Approach is an approach to design algorithms in which a bigger problem is broken down into smaller parts. Thus, it uses the decomposition approach. This approach is generally used by structured programming languages such as C, COBOL, FORTRAN. • Bottom-Up Approach is one in which the smaller problems are solved, and then these solved problems are integrated to find the solution to a bigger problem. Therefore, it uses composition approach. It is generally used with object oriented programming paradigm such as C++, Java, and Python.
  • 38. Department of CSE-NEC 38 S.No. Top-Down Approach Bottom-Up Approach 1. In this approach, the problem is broken down into smaller parts. In this approach, the smaller problems are solved. 2. It is generally used by structured programming languages such as C, COBOL, FORTRAN, etc. It is generally used with object oriented programming paradigm such as C++, Java, Python, etc. 3. It is generally used with documentation of module and debugging code. It is generally used in testing modules. 4. It does not require communication between modules. It requires relatively more communication between modules. 5. It contains redundant information. It does not contain redundant information. 6. Decomposition approach is used here. Composition approach is used here. 7. The implementation depends on the programming language and platform. Data encapsulation and data hiding is implemented in this approach.
  • 43. Department of CSE-NEC 43 Compilation Process in C • What is a compilation? The compilation is a process of converting the source code into object code or machine code. It is done with the help of the compiler. The compiler checks the source code for the syntactical or structural errors, and if the source code is error-free, then it generates the object code. The compilation process can be divided into four steps, • Pre-processing • Compiling, • Assembling, • Linking
  • 44. Department of CSE-NEC 44 Pre-processing The pre-processor takes the source code as an input, This phase includes: • Removal of Comments • Expansion of Macros • Expansion of the included files. The source code is the code which is written in a text editor and the source code file is given an extension filename.c. This source code is first passed to the pre-processor, and then the pre-processor expands this code. After expanding the code, the expanded code is passed to the compiler. The pre- processed output is stored in the filename.i • Compiling The code which is expanded by the pre-processor(filename.i) is passed to the compiler. The compiler converts this code into assembly code. Or we can say that the C compiler converts the pre-processed code into assembly code. The compiler phase output is stored in the filename.s
  • 45. Department of CSE-NEC 45 • Assembling: The assembly code is converted into object code by using an assembler. • In this phase the filename.s is taken as input and turned into filename.o by the assembler. This file contains machine-level instructions. At this phase, only existing code is converted into machine language, and the function calls like printf() are not resolved. • Linking: Mainly, all the programs written in C use library functions. These library functions are pre-compiled, and the object code of these library files is stored with '.lib' (or '.a') extension. The main working of the linker is to combine the object code of library files with the object code of our program. • Loading: linker creates the executable file(filename.exe). The loader will then load the executable file for the execution.
  • 47. Department of CSE-NEC 47 Constant Example Decimal Constant 10, 20, 450 etc. Real or Floating-point Constant 10.3, 20.2, 450.6 etc. Octal Constant 021, 033, 046 etc. Hexadecimal Constant 0x2a, 0x7b, 0xaa etc. Character Constant 'a', 'b', 'x' etc. String Constant "c", "c program", "c in javatpoint" etc. 68ul —> Unsigned Long Integer Constant 50l —> Long Integer Constant 30u —> Unsigned Integer Constant
  • 48. Department of CSE-NEC 48 #include<stdio.h> #include<conio.h> void main() { int q = 9 ; const int a = 10 ; q = 15 ; a = 100 ; // creates an error printf(“q = %dna = %d”, q, a ) ; } #include<stdio.h> #include<conio.h> #define PI 3.14 void main() { int a, area ; printf(“Enter the radius of the given circle here : “) ; scanf(“%d”, &a) ; area = PI * (a * a) ; printf(“The area of the circle is = %d”, area) ; }