Unit 1 C-Programming
Unit 1 C-Programming
Programming Paradigm
[email protected] 9/24/2020
3
Program Design Tools…..
Algorithm
[email protected] 9/24/2020
4
Program Design Tools…..
[email protected] 9/24/2020
5
Program Design Tools…..
Algorithm…..
Example 1: Find the simple interest of given number
Step 1: Start
Step 2 : Read principal , rate and time
Step 3 : Multiply principal , rate and time , divide by 100 and store it in SI
Step 4: Print result SI
Step 5: Stop
[email protected] 9/24/2020
6
Program Design Tools…..
Algorithm…..
Example 2: Find the sum of two numbers
Step 1: Start
Step 2 : Read the two numbers i.e. A,B
Step 3 : Add the number A and B and Store in sum i.e. sum=A+B
Step 4: Display or Print result sum
Step 5: Stop
[email protected] 9/24/2020
7
Program Design Tools…..
Flowchart
A flowchart is a diagrammatic or pictorial representation that
illustrates the sequence of operations to be performed. After
designing an algorithm , the next stage is to design a flowchart to
check the flow of logic running through it.
[email protected] 9/24/2020
8
Program Design Tools…..
Advantages of Flowchart
It is easier for a programmer to explain the logic of a program
through flowchart
It helps in effective analysis of the program
Easy to detect , locate and remove bugs in a program
Effective means of communication
Serve as documentation
With the help of flowchart coding becomes effective and faster
[email protected] 9/24/2020
9
Program Design Tools…..
Disadvantages of Flowchart
Very time consuming and laborious job
Flowcharts are difficult to maintain
Occupies space while documentation
Translation of flowchart to computer program is difficult
[email protected] 9/24/2020
10
Program Design Tools…..
Types of Flowchart
According to use and application of flowchart , there are two types
of flowchart. They are:
System flowchart
Program flowchart
[email protected] 9/24/2020
11
Program Design Tools…..
Types of Flowchart……..
System flowchart
Types of Flowchart……..
Program flowchart
[email protected] 9/24/2020
14
Program Design Tools…..
Terminal Box
[email protected] 9/24/2020
15
Program Design Tools…..
Decision Box
[email protected] 9/24/2020
16
Program Design Tools…..
Flow lines
[email protected] 9/24/2020
17
Examples:
Read L,B
A= L x B
Display A
[email protected] 9/24/2020
19
Self Practice
[email protected] 9/24/2020
20
Flowchart to find the greatest number among three input numbers
[email protected] 9/24/2020
21
Self practice
Algorithm
Step 1: start
Step 2: read name , class ,and marks for five subjects
Step 3: find the average mark.
Step 4: if the average is greater than or equal to 40 then print
“Pass” otherwise “Fail”
Step 5: stop
[email protected] 9/24/2020
22
Flowchart
Start
Read
name,class,m1,m2,m3,m4,m5
Avg=(m1+m2+m3+m4+m5)/5
Is Yes
Display Pass
Avg>=40
No
Display Fail
Self practice:
Computer scholarship are given on the following basis:
Marks scholarship
>=90 40%
>=70 and <90 35%
>=60 and <70 25%
<60 nil
The computer fee for a course is 20000. Draw a
flowchart which inputs the marks and computes the fee a
student has to pay
[email protected] 9/24/2020
24
Draw flowchart to display even numbers from 2 to
50 and find the sum.
Algorithm:
Step 1: start
Step 2: store 2 to A
Step 3: display A
Step 4: store A in Sum
Step 5: add 2 in A
Step 6: Is A is less than 50, if yes, repeat 3,4,5 and 6 step
if No, goto step 7
Step 7: display Sum
Step 8 : stop
[email protected] 9/24/2020
25
Pseudo code:
[email protected] 9/24/2020
28
Difference between Algorithm and Flowchart:
Algorithm Flowchart
1. It is step by step operation/solution to a 1. It is a type of diagram that represents
particular problem. an algorithm.
2. It doesn't use any specific boxes/symbols. 2. It uses various kinds of boxes/symbols
which are interlinked with arrows/lines.
[email protected] 9/24/2020
29
Testing and Debugging:
Debugging:
The process of detecting , locating and correcting
errors is called Debugging
Done by developer
Need to know the source code
[email protected] 9/24/2020
30
Error(Bug) and types of errors
[email protected] 9/24/2020
31
Types of errors:
[email protected] 9/24/2020
32
Types of errors:
Syntax error:
Syntax errors are detected at compile time
For example: missing semi-colon or misspelling
If a program contains syntax error, it will not be executed and
will not produce output
This type of error is easier, faster and cheaper to debug
[email protected] 9/24/2020
33
Types of errors:
[email protected] 9/24/2020
34
Types of errors:
Run-Time error:
Occur at run time
Programs terminate unexpectedly due to illegal operation such
as dividing a number by zero(0)
[email protected] 9/24/2020
35
Language Processor/translator
[email protected] 9/24/2020
37
Types of Language Processor/translator
[email protected] 9/24/2020
38
Types of Language Processor/translator
Assembler:
The Assembler is used to translate the program written in Assembly language into
machine code. The source program is a input of assembler that contains assembly
language instructions. The output generated by assembler is the object code or
machine code understandable by the computer.
[email protected] 9/24/2020
39
Types of Language Processor/translator
Compiler:
The language processor that reads the complete source program written in high
level language as a whole in one go and translates it into an equivalent program
in machine language is called as a Compiler.
Example: C, C++, C#, Java
[email protected] 9/24/2020
40
Types of Language Processor/translator
Interpreter:
The translation of single statement of source program into machine code is
done by language processor and executes it immediately before moving on to
the next line is called an interpreter.
Example: Perl, Python and Matlab.
[email protected] 9/24/2020
41
Difference between Interpreter and Compiler
Compiler Interpreter
1. A compiler is a program which coverts the entire 1. Interpreter takes a source program and runs it
source code of a programming language into line by line, translating each line as it comes to it.
executable machine code for a CPU.
4. Compiler takes large amount of time to analyze 4. Interpreter takes less amount of time to
the entire source code but the overall execution analyze the source code but the overall execution
time of the program is comparatively faster. time of the program is slower.
[email protected] 9/24/2020
Programming Paradigm
9/24/2020 [email protected] 42
Programming Paradigm
9/24/2020 [email protected] 43
Programming Paradigm…
9/24/2020 [email protected] 44
1. Imperative Programming Paradigm
9/24/2020 [email protected] 45
Advantages of Imperative Programming Paradigm
9/24/2020 [email protected] 46
Procedural Programming paradigm:
Procedural languages are statement oriented with the variables holding values. In this
language the execution of a program is modeled as a series of states of variable
locations. It uses a linear or top-down approach.
Examples of Procedural programming paradigm:
C : developed by Dennis Ritchie and Ken Thompson
C++ : developed by Bjarne Stroustrup
Java : developed by James Gosling at Sun Microsystems
ColdFusion : developed by J J Allaire
Pascal : developed by Niklaus Wirth
9/24/2020 [email protected] 47
Object Oriented paradigm:
The Object Oriented paradigm is addressed on the concept of the object. Everything
is focused on objects.
More emphasis is on data rather procedure. It can handle almost all kind of real life
problems which are today in scenario.
Examples of Object Oriented programming paradigm:
Simula : first OOP language developed by Ole-Johan Dahl and Kristen Nygaard.
Java : developed by James Gosling at Sun Microsystems
C++ : developed by Bjarne Stroustrup
Visual Basic .NET : developed by Microsoft
Python : developed by Guido van Rossum
Ruby : developed by Yukihiro Matsumoto
Smalltalk : developed by Alan Kay, Dan Ingalls, Adele Goldberg
9/24/2020 [email protected] 48
Parallel processing approach
9/24/2020 [email protected] 49
2. Declarative Programming Paradigm
9/24/2020 [email protected] 50
2. Declarative Programming Paradigm…
9/24/2020 [email protected] 51
2. Declarative Programming Paradigm…
9/24/2020 [email protected] 52
2. Declarative Programming Paradigm…
9/24/2020 [email protected] 55
Objectives/Aims of System/Program Development Life Cycle
9/24/2020 [email protected] 56
Phases /Stages of SDLC
9/24/2020 [email protected] 59
Design
It is the most creative phase in Software Development Life Cycle.
The goal of this phase is to transform the requirement
specification into a structure or plan.
It is the process of planning and problem solving for a software
solution. It implicates software developers and designers to
define the plan for a solution. The output of this phase is
Software Design Document (SDD).
9/24/2020 [email protected] 60
Building or Coding:
In this phase, the system and software design documents are prepared
as per the requirement specification document. This helps define
overall system architecture.
It is the logical phase of the Software Development Life Cycle. The
output of this phase is program code.
9/24/2020 [email protected] 61
Testing:
Just after coding phase, testing is carried out to know the
outcome of application.
Testing is made to know the actual result and the expected
result. This is most important and powerful phase. Effective
testing will provide high quality software products, lower
maintenance costs, and more accurate and reliable results.
9/24/2020 [email protected] 62
Deployment
Once the software testing phase is over and no bugs or errors
left in the system then the final deployment process starts.
Based on the feedback given by the project manager, the final
software is released and checked for deployment issues if any.
9/24/2020 [email protected] 63
Maintenance
9/24/2020 [email protected] 64
Software Development Model(SDLC Models)
There is various software development approaches defined and designed which are used during
development process of software, these approaches are also referred as "Software
Development Process Models". Each process model follows a particular life cycle in order to
ensure success in process of software development. Some of the SDLC Models are:
Waterfall Model
Spiral Model
Iterative Model
Incremental Model
Prototyping Model
V -Shaped Model
RAD Model
9/24/2020 [email protected] 65
Software Development Model(SDLC Models)…
Waterfall Model :
It is referred as a linear-sequential life cycle model. It defines some basic tasks,
which are carried out in sequence: Analysis, Design ,Coding, Testing, Deployment,
Implement.
In a waterfall model, each phase must be completed in its entirety before the next
phase can begin. At the end of each phase, a review takes place to determine if the
project is on the right path and whether or not to continue or discard the project.
This type of model is basically used for the project which is small and there are no
uncertain requirements.
In this model the testing starts only after the development is complete. In waterfall
model phases do not overlap.
9/24/2020 [email protected] 66
Software Development Model(SDLC Models)…
Waterfall Model :
Coding
9/24/2020 [email protected] 67
Software Development Model(SDLC Models)…
9/24/2020 [email protected] 68
Software Development Model(SDLC Models)…
9/24/2020 [email protected] 69
Software Development Model(SDLC Models)…
Iterative Model:
9/24/2020 [email protected] 70
Software Development Model(SDLC Models)…
Iterative Model:
9/24/2020 [email protected] 71
Software Development Model(SDLC Models)…
9/24/2020 [email protected] 72
Software Development Model(SDLC Models)…
9/24/2020 [email protected] 73
Software Development Model(SDLC Models)…
Spiral model
9/24/2020 [email protected] 74
Software Development Model(SDLC Models)…
Spiral model
1. Planning /Determine
Objectives 2. Risk Analysis
1.Planning/Determine Objectives:
Requirements are gathered from the
customers and the objectives are
identified, elaborated and analyzed at
the start of every phase. Then
alternative solutions possible for the
phase are proposed in this quadrant. 4. Plan the next 3. Develop next version
phase of the Product
9/24/2020 [email protected] 75
Software Development Model(SDLC Models)…
Spiral model…
2. Risk analysis
During the second quadrant all the possible solutions are evaluated to select the
best possible solution. Then the risks associated with that solution is identified
and the risks are resolved using the best possible strategy. At the end of this
quadrant, Prototype is built for the best possible solution.
9/24/2020 [email protected] 76
Software Development Model(SDLC Models)…
Spiral model…
9/24/2020 [email protected] 77
Software Development Model(SDLC Models)…
Spiral model…
9/24/2020 [email protected] 78
Software Development Model(SDLC Models)…
9/24/2020 [email protected] 79
Software Development Model(SDLC Models)…
9/24/2020 [email protected] 80
Software Development Model(SDLC Models)…
Prototyping Model
9/24/2020 [email protected] 81
Software Development Model(SDLC Models)…
Prototyping Model
Prototyping
Initial Customer
Design
requirements Evaluation
Customer
satisfied
Review &
Update
9/24/2020 [email protected] 82
Software Development Model(SDLC Models)…
9/24/2020 [email protected] 83
Software Development Model(SDLC Models)…
9/24/2020 [email protected] 84
Software Development Model(SDLC Models)…
Incremental Model
9/24/2020 [email protected] 85
Software Development Model(SDLC Models)…
Incremental Model
9/24/2020 [email protected] 86
Software Development Model(SDLC Models)…
9/24/2020 [email protected] 87
Software Development Model(SDLC Models)…
9/24/2020 [email protected] 88
Software Development Model(SDLC Models)…
9/24/2020 [email protected] 89
Review questions:
Define Programming language. Explain low level language and high level
language with examples.
What is language processor? Differentiate between Interpreter and
Compiler
What is algorithm? List its characteristics
What is flowchart? Write the different symbols used in flowchart with
their meaning
9/24/2020 [email protected] 90
Review questions:
Write an algorithm and draw flowchart to test whether the number is
positive , negative or zero
What is SDLC/PDLC? Explain Waterfall model with its advantages and
disadvantages
What is spiral model? List its advantages and disadvantages.
9/24/2020 [email protected] 91
Review questions:
Explain the various types of errors.
Explain context diagram , DFD and Decision Table in brief
9/24/2020 [email protected] 92
MCQ:
Which of the following is object oriented language?
a. Basic
b. C
c. Java
d. FORTAN
9/24/2020 [email protected] 93
MCQ:
Risk analysis is key feature in ………….. Software process model
a. Waterfall
b. Spiral
c. Prototype
d. Reverse
9/24/2020 [email protected] 94
MCQ:
The diamond shaped symbol is used in the flowchart to show the…..
a. Decision
b. Process
c. Input
d. Stop
9/24/2020 [email protected] 95
MCQ:
In program development life cycle, design phase is followed by ….
a. Coding
b. Testing
c. Maintenance
d. None of the above
9/24/2020 [email protected] 96
MCQ:
Which of the following error can’t be detected by the compiler?
a. Syntax error
b. Run time error
c. Logical error
d. Both b and c
9/24/2020 [email protected] 97
MCQ:
What is the operation that is used in algorithm to repeat the particular
block of statement?
a. Selection
b. Sequence
c. Iteration
d. Reverse
9/24/2020 [email protected] 98
MCQ:
The mnemonics are used in
a. Assembly language
b. High level language
c. Machine level language
d. None
9/24/2020 [email protected] 99
MCQ:
Language in which single statement can be written to accomplish
substantial tasks is termed as
a. Machine level language
b. Assembly language
c. High level language
d. None