CIT301 SUMMARY FROM NOUNGEEKS.
COM
Low level language
This type of language is language. The two major language closer to the
machine compared with the human natural examples are the
Machine language and the Assembly.
Assembly Language: Assembly Language uses MNEMONICS (symbols)
to represent data and instructions. Such program eliminates problems
associated with machine language. Computer cannot execute directly a
program written in assembly language, it requires a translator called
assembler.
Advantages of Assembly Language
• It allows complex jobs to run in a simpler way.
• It is memory efficient, as it requires less memory.
• It is faster in speed, as its execution time is less.
Disadvantages of Assembly Language
• It is machine dependent; the programmer must be knowledgeable in
both subject area and the operations of the machine.
• It is cumbersome though less cumbersome than that of machine
language.
• Very expensive to develop
• It consumes time
High Level Language
A high-level language is a problem orientated programming language,
whereas a low-level language is machine oriented. The source programs are
written in human readable languages like English instead of mere symbols.
In other words, a high-level language is a convenient and simple means of
describing the information structures and sequences of actions required to
perform a particular task.
Advantages of High-Level Language
• The person writing the program does not need to know anything
about the computer in which the program will be run (Machine
Independent)
• The programs are portable
• Very easy to learn and write
Disadvantages of High-Level Language
• It takes additional translation times to translate the source to
machine code.
• High level programs are comparatively slower than low level
programs.
• Compared to low level programs, they are generally less memory
efficient.
• Cannot communicate directly with the hardware
Features of High-Level Language
• Machine independent
• Problem oriented
• Ability to clearly reflect the structure of program written in it.
• Readability
• Programs are portable.
Characteristics of a Good Program
• Transferability- Must be able to work on any computer machine.
• Reliability- It can be relied upon to do what it is expected to do.
• Efficiency/cost saving- It must not cost more than its benefits and
enables problem to be solved appropriately, quickly and efficiently.
• Simplicity- It should be as simple as possible to understand.
• Understandability/Readability- It must be readable and
understandable by other programmers and end users.
Flexibility/Adaptability / Maintainability- A good program must be flexible
adaptable and maintainable in order to suit user’s need.
Abstraction
This is called raising the level of abstraction. Every time you raise the level
of abstraction in a programming language, you get more program (as
measured in terms of bits) for less work. The language at which you
communicate with the computer can also be altered into something closer
to the way we communicate in English.
A module is basically a set of interrelated files that share their
implementation details but hide it from the outside world. The main
advantages of modular programming approach, includes ease of use,
reusability, and ease of maintenance.
Modularity
Modular programming is the process of subdividing a computer program
into separate sub-programs. A module is a separate software component. It
can be used in a variety of applications and functions with other
components of the system.
Advantages of Using Modular Programming Approach
Ease of Use: This approach allows simplicity, as lines of program code can
be accessed in the form of modules, rather than focusing on the entire
thousands and millions of lines code. This allows ease in debugging the
code and prone to less error.
Reusability: It allows the user to reuse the functionality with a different
interface without typing the whole program again.
Ease of Maintenance: It helps in less collision at the time of working on
modules, helping a team to work with proper collaboration while working
on a large application.
Modular Programming in C
C is called a structured programming language because to solve a large
problem, C programming language divides the problem into smaller
modules called functions or procedures each of which handles a particular
responsibility. The program which solves the entire problem is a collection
of such functio
Modularization has several benefits, especially on large and complex
programs:
• modules can be re-used in several projects;
• changing the implementation details of a modules does not require to
modify the clients using them as far as the interface does not change;
• faster re-compilation, as only the modules that have been modified
are actually re-compiled;
• self-documenting, as the interface specifies all that is required to
know to use the module;
• easier debugging, as modules dependencies are clearly specified and
every module can be tested separately.
Structured programming Concept
In structured programming design, programs are broken into different
functions these functions are also known as modules, subprogram,
subroutines and procedures.
Structured programming minimizes the chances of the function affecting
another. It allows for clearer programs code. It made global variables to
disappear and replaced by the local variables.
The languages that support Structured programming approach are:
•C
•C++
•Java
•C#
•Pascal
Advantages of Structured programming
•It is user friendly and easy to understand.
•Similar to English vocabulary of words and symbols.
•It is easier to learn.
•They require less time to write.
Programming paradigms
A programming paradigm, or programming model, is an approach to
programming a computer based on a mathematical theory or a coherent set
of principles.
Imperative paradigm
This paradigm is based on the ideas of a Von Neummann architecture. A
command has a measurable effect on the program and the order of
commands is important. First do this and next do that. Its main
characteristics are incremental change of the program state (variables) as a
function of time; execution of commands in an order governed by control
structures; and the use of procedures, abstractions of one or more actions,
which can be called as a single command. Examples: Fortran, Algol, Basic,
C, Pascal.
Functional paradigm
This paradigm is based on mathematics and theory of functions. The values
produced are non-mutable and plays a minor role compared to imperative
program. All computations are done by applying functions with no side
effects. Functions are firsts class citizens. Evaluate an expression and use
the resulting value for something. Example: Haskell, Clojure Check for
Functional paradigm
Functional paradigm
This paradigm is based on mathematics and theory of functions. The values
produced are non-mutable and plays a minor role compared to imperative
program. All computations are done by applying functions with no side
effects. Functions are firsts class citizens. Evaluate an expression and use
the resulting value for something. Example: Haskell, Clojure Check for
Functional paradigm
Logical paradigm
The logic paradigm fits well when applied in problem domains that deals
with the extraction of knowledge from basic facts and relations. Is based on
axioms, inference rules, and queries. Program execution becomes a
systematic search in a set of facts, making use of a set of inference rules.
Answer a question via search for a solution. Examples: Prolog and List.
Brief History of C
The C programming language is a structure-oriented programming
language, developed at Bell Laboratories in 1972 by Dennis Ritchie.
C programming language features were derived from an earlier
language called “B” (Basic Combined Programming Language – BCPL)
C language was invented for implementing UNIX operating system.
In 1978, Dennis Ritchie and Brian Kernighan published the first edition
a“The C Programming Language” and is commonly known as K&RC.
In 1983, the American National Standards Institute (ANSI) established
a committee to provide a modern, comprehensive definition of C. The
resulting definition, the ANSI standard, or “ANSI C” was completed late
1988.
Many of C’s ideas & principles were derived from the earlier language B,
thereby naming this new language “C”.
Machine Language: This is the only language computer
understands. It is the native language of the computer. The
computer directly executes a program written in machine language.
These programs are coded using strings of 0’s and 1’s. It doesn’t
need a translator.
Uses of C
The C programming language is used for developing system
applications that forms a major portion of operating systems such
as Windows, UNIX and Linux. Below are some examples of C being
used:
Database systems
Graphics packages
Word processors
Spreadsheets
The structure of a C program is a protocol (rules) to the
programmer, which he has to follow while writing a C program. A
number of files are used in a C Program. Examples of these files
are: source, object, header and executable files.
Keywords
Keywords are the words whose meaning has already been
explained to the C compiler. The keywords cannot be used as
variable names because if we do so we are trying to assign a new
meaning to the keyword, which is not allowed by the computer.
A data type defines a set of values and the operations that can be
defined on those values. Data types are especially important in C
programming language All operations are type checked by the
compiler for type compatibility.
Data Types
In the C programming language, data types refer to a domain of
allowed values & the operations that can be performed on those
values. The type of a variable determines how
much space it occupies in storage and how the bit pattern stored is
interpreted. There are 4 fundamental data types in C, which are-
char, int, float &, double. Char is used to store any single character;
int is used to store any integer value, float is used to store any
single precision floating point number & double is used to store
any double precision floating point number
Constants
A constant is an entity that doesn’t change whereas a variable is an
entity that may change. C constants can be divided into two major
categories:
•Primary Constants
•Secondary Constants
Rules for Constructing Integer Constants
An integer constant must have at least
one digit. o It must not have a decimal
point.
It can be either positive or negative.
If no sign precedes an integer constant it is assumed to be
positive. o No commas or blanks are allowed within an
integer constant.
The allowable range for integer constants is -32768to
32767. o Eg.: 426, +782,-8000, -7605
Variables and Variable Declaration
Variables are names that are used to store values. It can take
different values but one at a time. A data type is associated with
each variable & it decides what values the variable can take.
Statements
Statements are the primary building blocks of a program. A
program is a series of statements with some necessary
punctuation.
A statement is a complete instruction to the computer. In C,
statements are indicated by a semicolon at the end.
Arithmetic operators
These are used to perform mathematical calculations like addition,
subtraction, multiplication, division and modulus.
Jump Statements
The break Statement
The break statement provides an early exit from for, while, and do,
just as from switch. A break causes the innermost enclosing loop or
switch to be exited immediately. When break is encountered inside
any loop, control automatically passes to the first statement after
the loop.
The continue Statement
The continue statement is related to break, but less often used; it
causes the next iteration of the enclosing for, while, or do loop to
begin. In the while and do, this means that the test part is executed
immediately; in the for, control passes to the increment step.
A function is a block of organized, reusable code that is used to
perform a single, related action. Functions provide better
modularity for your application and a high degree of code reusing
Different programming languages name them differently, for
example, functions, methods, sub-routines, procedures, etc.
function interface is a declaration of a function that specifies the
function's name and type signature (arity, data types of parameters,
and return type), but omits the function body.
Monolithic Vs Modular Programming:
• Monolithic Programming indicates the program which
contains a single function for the large program.
• Modular programming helps the programmer to divide the
whole program into different modules and each module is
separately developed and tested. Then the linker will link all
these modules to form the complete program.
• On the other hand, monolithic programming will not divide
the program and it is a single thread of execution. When the
program size increases it leads inconvenience and difficult to
maintain.
Disadvantages of monolithic programming:
• Difficult to check error on large programs.
• Difficult to maintain. 3. Code can be specific to a particular
problem. i.e., it cannot be reused.
Advantage of modular programming
• Modular programs are easier to code and debug.
• Reduces the programming size.
• Code can be reused in other programs.
• Problem can be isolated to specific module so easier to find
the error and correct it.
Function
A function is a group of statements that together perform a task.
Every C program has at least one function, which is main(), and all
the most trivial programs can define additional functions.
Function Declaration OR Function Prototype
1. It is also known as function prototype .
2. It inform the computer about the three things
Name of the function
Number and type of arguments received by the function.
Type of value return by the function
Function Definition
1. It consists of code description and
code of a function . It consists of two
parts
Function header
Function coding
User Define Function:
A function that is declare, calling and define by the user is called
user define function.
Every user define function has three parts as:
1. Prototype or Declaration
2. Calling
3. Definition
Function Categories
There are four main categories of the functions these are as
follows:
1. Function with no arguments and no return values.
2. Function with no arguments and a return value.
3. Function with arguments and no return values.
4. Function with arguments and return values.
String
A string is a series of characters treated as a single unit. A string
may include letters, digits and various special characters such as +,
-, *, / and $.
Structure
A Structure is a user defined data type that can store related
information together. The variable within a structure is of different
data types and each has a name that is used to select it from the
structure.