Engineering Notes for Computer Programming (C-Programming) matching with current ioe syllabus and important from IOE final exam point of view Here you can read most recent and updated notes in simple language .
What is Software?
Software:- software is a program or collection of program that uses capabilities of computer
to perform a specific task. There are three types of software
- System software:-These software that helps to operate a particular system is called system software for eg:- operating system, device driver etc.
- Application software:-These software are heavily oriented toward data storing, analyzing data retrieving. These are focused on growing business of an organization for eg:-ms office,games,all app ( google chrome,pubg,pumori etc).
This software is also divided into two types
- Packaged software:- those application software targeting huge mass is called packaged software for eg:-msoffice,google chrome etc.
- Tailored software:-those application software focusing small mass is called tailores software.eg:- app of nce college,app of nicasia etc
- Utility software:-those software are focused on fine tuning the performance of computer system in any situation. They helps in increasing the performance of computer system or helps to make computer system intact. For eg:-antivirus,window defender,firewall etc.
Programming language
What do you mean by Program?
Program:-sets of command or instruction that tells computer to perform a specific task.
What do you mean by programming language ?
Programming language:- programming language is a intermediate tools that helps to communicate human with computer. i.e it is a intermediate language through which we we can instruct computer to perform a specific task.
There are two types of programming language.
They are
- low level programming language:- if program is written in computer understandable language then it is called low level programming language.
It is also divided into two types. they are
1.machine language:-
- machine or hardware dependent
- programming is done using binary code(combinations of 0's and 1's)
- its is very hard and tedious for a programmer to program
- program execution time is very fast.
2. Assembly language:-programming is done using binary code(0's and 1's) and mnemonics (ADD,SUB,MUL,DIV etc).
- it is a bit easier for a programmer to program than machine language.
- execution time is a bit more than than machine language(because we need to convert mnemonics to binary code)
Assembly language---------------> machine language
Assembler
- High level programming language :-program written by using natural language(like English) and different symbols is called high level programming language.
- very easy for programmer to program
- execution time is more than low level programming language
high level language--------------------> machine language
compiler/interpreter
Compiler, Interpreter and Assembler
Compiler and interpreter are used to convert the high level language into machine level
language. The program written in high level language is known as source program and
the corresponding machine level language program is called as object program. Both
compiler and interpreter perform the same task but there working is different. Compiler
read the program at-a-time and searches the error and lists them. If the program is error
free then it is converted into object program. When program size is large then compiler
is preferred. Whereas interpreter read only one line of the source code and convert it to
object code. If it check error, statement by statement and hence of take more time.
An assembler program creates object code by translating combinations of mnemonics
and syntax for operations and addressing modes into their numerical equivalents. This
representation typically includes an operation code (”opcode”) as well as other control
bits and data. The assembler also calculates constant expressions and resolves symbolic
names for memory locations and other entities.
Structured Programming
Structured programming is a programming paradigm aimed at improving the clarity,
quality, and development time of a computer program by making extensive use of subroutines, block structures, for and while loops—in contrast to using simple tests and
jumps such as the go to statement which could lead to ”spaghetti code” causing difficulty to both follow and maintain.
Design FlowChart and Algorithm
An algorithm is a solution to a computer programming problem. In other words a step
by step procedure for developing a problem is called an algorithm. Algorithms can be
written in two different ways.
1.Pseudocode English like steps that describe the solution. Pseudocode is an artificial and informal language that helps programmers develop algorithms.
2.FlowChart Pictures Detailing with specific blocks detailing out the logical flow
of the solution. For a better understanding of an algorithm, it is represented
pictorially. The pictorial representation of an algorithm is called a Flow Chart.
The algorithm and flowchart to add two numbers can be stated as:
(a) Step1: Input numbers as a and b
(b)
Step2: Sum = x + y
(c)
Step3: Print the sum
Constant and Variables
Constants refer to fixed values that the program may not alter during its execution.
These fixed values are also called literals. Constants can be of any of the basic data
types like an integer constant, a floating constant, a character constant, or a string
literal. There are enumeration constants as well .Constants are treated just like regular
variables except that their values cannot be modified after their definition.
A variable is nothing but a name given to a storage area that our programs can manipulate. Each variable in C has a specific type, which determines the size and layout
of the variable’s memory; the range of values that can be stored within that memory;
and the set of operations that can be applied to the variable. The name of a variable
can be composed of letters, digits, and the underscore character. It must begin with
either a letter or an underscore. Upper and lowercase letters are distinct because C is
case-sensitive.
Rules for writing variable name in C
- A variable name can have letters (both uppercase and lowercase letters), digits
and underscore only.
- The first letter of a variable should be either a letter or an underscore. However,
it is discouraged to start variable name with an underscore. It is because variable
name that starts with an underscore can conflict with a system name and may
cause error.
- There is no rule on how long a variable can be. However, the first 31 characters
of a variable are discriminated by the compiler. So, the first 31 letters of two
variables in a program should be different.
Operators in C
An operator is a symbol that tells the compiler to perform specific mathematical or
logical functions. C language is rich in built-in operators and provides the following
types of operators.
• Arithmetic Operator
• Relational Operator
• Logical Operator
• Bitwise Operator
• Assignment Operator
• Misc Operator
Rules for Evaluation of Expression
- First, parenthesized sub expression from left to right are evaluated.
- If parentheses are nested, the evaluation begins with innermost sub expression.
- The precedence rule is applied in determining the order of operands in evaluating
sub expressions.
- Arithmetic expressions are evaluated from left to right using the rules of precedence.
- When parentheses are used, the expressions within the parentheses assume highest
priority
Control Statements in C
C provides two types of Control Statements
- Branching Structure
- Looping Structure
Call by Value
If data is passed by value, the data is copied from the variable used in for example main()
to a variable used by the function. So if the data passed (that is stored in the function
variable) is modified inside the function, the value is only changed in the variable used
inside the function.
Call by Reference
If data is passed by reference, a pointer to the data is copied instead of the actual
variable as is done in a call by value. Because a pointer is copied, if the value at that
pointers address is changed in the function, the value is also changed in main().