Module 1 PDF
Module 1 PDF
Semester I
MG University, Kottayam
Syllabus
Module 1
Introduction to programming, Classification of computer
languages, Language translators (Assembler, Compiler,
Interpreter), Linker, Characteristics of a good programming
language, Factors for selecting a language, Subprogram,
Purpose of program planning, Algorithm, Flowchart, Pseudo
code, Control structures (sequence, selection, Iteration), Testing
and debugging
Module 2
C Character Set, Delimiters, Types of Tokens, C Keywords,
Identifiers, Constants, Variables, Rules for defining variables,
Data types, C data types, Declaring and initialization of variables,
Type modifiers, Type conversion, Operators and Expressions-
Properties of operators, Priority of operators, Comma and
conditional operator, Arithmetic operators, Relational
operators, Assignment operators and expressions, Logical
Operators, Bitwise operators
Module 3
Input and Output in C – Formatted functions, unformatted
functions, commonly used library functions, Decision
Statements If, if-else, nested if-else, if-else-if ladder, break,
continue, go-to, switch, nested switch, switch case and nested if.
Loop control- for loops, nested for loops, while loops, do while
loop.
Module 4
Array, initialization, array terminology, characteristics of an
array, one dimensional array and operations, two dimensional
arrays and operations. Strings and standard functions, Pointers,
Features of Pointer, Pointer and address, Pointer declaration,
void wild constant pointers, Arithmetic operations with
pointers, pointer and arrays, pointers and two dimensional
arrays.
Module 5
Basics of a function, function definition, return statement, Types
of functions, call by value and reference. Recursion -Types of
recursion, Rules for recursive function, direct and indirect
recursion, recursion vs iterations, Advantages and
disadvantages of recursion. Storage class, Structure and union,
Features of structures, Declaration and initialization of
structures, array of structures, Pointer to structure, structure
and functions, typedef, bit fields , enumerated data types, Union,
Dynamic memory allocation, memory models, memory
allocation functions.
Book of Study:
1. Ashok Kamthane - Programming in C, Third Edition, Pearson
Education
2. P K Sinha & Priti Sinha - Computer Fundamentals, Fourth
Edition, BPB Publications.
Reference:
1. E. Balaguruswamy -Programming in ANSI C ,Seventh
Edition, McGraw Hill Education
2. Byron Gotfried - Programming with C, Second Edition,
Schaums Outline series. McGraw Hill
Module 1
INTRODUCTION TO PROGRAMMING
Computer is an electronic device that accepts data, process
those data, store the data and results the output. Data are
accepted by keyboard or any other input devices. Data are
processed by means of central processing unit or simply CPU.
Some kind of memories are used to store the data and results.
And these results as delivered to the output or visualized by
monitors.
LANGUAGE TRANSLATORS
1. Assembler
2. Compiler
3. Interpreter
Assembler
Compiler
Interpreter
Linker
Naturalness
A good language should be natural for the application area for
which it is designed. That is, it should provide appropriate
operators, data structures, control structures and a natural
syntax to facilitate programmers to code their problems easily
and efficiently. FORTRAN and COBOL are good examples of
languages possessing high degree of naturalness in scientific
and business application areas, respectively.
Abstraction
Abstraction means ability to define and then use complicated
structures or operations in ways that allow many of the details
to be ignored. The degree of abstraction allowed by a language
directly affects its ease of programming.
Efficiency
Programs written in a good language are translated into
machine code efficiently, are executed and require relatively
less space in memory. That is, a good programming language is
supported with a good language translator (a compiler or an
interpreter) that gives due consideration to space and time
efficiency.
Compactness
In a good language, programmers should be able to express the
intended operations concisely without losing readability.
Programmers generally do not like a verbose language because
they need to write too much.
Locality
A good language should be such that while writing a program, a
programmer need not jump around the visually as the text of a
program is prepared. This allows the programmer to
concentrate almost solely on the part of the program around the
statement currently being worked with. COBOL and to some
extent C and Pascal lack locality because data definitions are
separated from processing statements, perhaps by many pages
of code, or have to appear before any processing statement in
the function/procedure.
Extensibility
A good language should also allow extensions through a simply,
natural and neat mechanism. Almost all languages provide
subprogram definition mechanisms for the purpose, but some
languages are weak in this aspect.
Popularity
This is a very important one. You are more likely to find people
to collaborate with if you use a popular language. You are also
more likely to find reference material and other help.
Language-domain match.
Select a language that matches your problem domain. You can
do this by looking at what other people in your field are using.
Look at the code that solves problems that you are working on.
Availability of libraries
If there's a library that solves your problem well, then it will be
helpful to choose the language for your need.
Efficiency
Languages compilers should be efficient. Look at the efficiency
of compilers or interpreters for your language. Be aware that
interpreted code will run properly.
Expressiveness
The number of lines of code you create per hour is not a strong
function of language, so favor languages that are expressive or
powerful.
Tool Support
Popularity usually buys tool support. Some languages are easier
to write tools. If you are a tool-oriented user, choose a language
with good tool support.
SUBPROGRAM
A subprogram is a program called by another program to
perform a particular task or function for the program. When a
task needs to be performed multiple times, you can make it into
a separate section. The complete program is thus made up of
multiple smaller, independent subprograms that work together
with the main program.
Problem Definition
Problem Analysis
Algorithm Development
Coding & Documentation
Problem Definition
In this phase, we define the problem statement and we decide
the boundaries of the problem. In this phase we need to
understand the problem statement, what is our requirement,
what should be the output of the problem solution. These are
defined in this first phase of the program development life cycle.
Problem Analysis
In phase 2, we determine the requirements like variables,
functions, etc. to solve the problem. That means we gather the
required resources to solve the problem defined in the problem
definition phase. We also determine the bounds of the solution.
Algorithm Development
During this phase, we develop a step by step procedure to solve
the problem using the specification given in the previous phase.
This phase is very important for program development. That
means we write the solution in step by step statements.
Maintenance
During this phase, the program is actively used by the users. If
any enhancements found in this phase, all the phases are to be
repeated again to make the enhancements. That means in this
phase, the solution (program) is used by the end user. If the user
encounters any problem or wants any enhancement, then we
need to repeat all the phases from the starting, so that the
encountered problem is solved or enhancement is added.
Algorithm
Any problem can be ever followed by sequence of steps or
procedures. Those sequence of steps or procedures are termed
as algorithm.
1. START
2. READ NUM1
3. READ NUM2
4. SUMNUM1+NUM2
5. PRINT SUM
6. END
Algorithm should be
1. Simple
2. Short
3. Understandable
4. Keep proper sequence
5. maintain ethical logic
6. Result oriented.
1. Start
2. Read Num1
3. Read Num2
4. Is (Num1>Num2)?
5. Yes: Print Num1 is Large, GOTO Step 7
6. Else: Print Num2 is Large
7. End
Flowchart
The pictorial or graphical representation of flow of a program is
known as flowchart. If the algorithms or programs are displayed
in the form of a picture then it will be more noticeable and
Pseudo code
The term pseudo means false. The false codes used to represent
the flow of execution of a program is known as pseudo codes.
Usually programmers use pseudo codes for rough work on their
problem solving. Most probably, they use pen and papers for
their rough programming work. They should not bother syntax
or semantics of any high level programming languages.
Rd N1, N2
N1>N2?
Y: Prn N1
N: Prn N2
CONTROL STRUCTURES
A control structure is a block of programming that analyzes
variables and chooses a direction in which to go based on given
parameters. Any computer program can be written using the
basic control structures. They can be combined in any way
necessary to deal with a given problem. The control structures
are:
1. Sequence
2. Selection
3. Iteration
Sequence
Selection
Iteration