Programming in C-1
Programming in C-1
The memory unit sends a set of instructions to the control unit. Then the control
unit in turn converts those instructions. After that these instructions are converted
to control signals.
These control signals help in prioritizing and scheduling the activities. Thus, the
control unit coordinates the tasks inside the computer in sync with the input and
output units.
Output
● Analog Computer
● Digital Computer
● Hybrid Computer
It accepts the raw data as digits or numbers and processes it with programs
stored in its memory to produce output.
All modern computers like laptops and desktops that we use at home or office
are digital computers.
Hybrid Computer
Hybrid Computer has features of both analog and digital computer.
It is fast like analog computer and has memory and accuracy like digital
computers. It can process both continuous and discrete data.
Theses monster machines are capable to play their role in the field of weather
forecasting, quantum mechanics and physical simulation (spaceship
aerodynamics and testing of nuclear weapons.
Minicomputers are multiprocessing system and can support upto 200 user at a
time but the power of processing is not as great as the mainframe and
supercomputers.
System Software are designed to control the operation and extend the processing
functionalities of a computer system. System software makes the operation of a
computer more fast, effective, and secure. Example: Operating system,
programming language, Communication software, etc.
Application Software
Application Software is a program that does real work for the user. It is mostly
created to perform a specific task for a user.
You can also install multiple Application Software on a single System Software.
You can store this kind of software on CDs, DVDs, flash derive, or keychain
storage devices. Example: Word-processing, Spreadsheet, Database, etc.
Software Development Model
● Waterfall Model
● Iterative / Prototype Model
● Spiral Model
Waterfall Model
Prototype Model
Spiral Model
Problem Statement or
Software development Problem Identification
lifecycle(SDLC)
Algorithm &
Flowchart Design
Coding
Compile &
Execution
Testing &
Debugging
Maintenance
& Support
Program
Basic commands that instructs the computer system to do anything are called
instructions.
The variables can represent numeric data, text or graphical data. Without
computer programs computer are useless.
Programming Language
● A set of rules that provides a way of instructing the computer to perform
certain tasks is called programming language
● A programming language is a vocabulary and set of grammatical rules for
instructing a computer or computing device to perform specific tasks.
● A programming language is a formal language comprising a set of strings that
produce various kinds of machine code output.
Types of Programming Language
● Low level or Machine level language
● Assembly level language
● High level language
Low Level language
● A low level language are mostly written with 1’s or 0’s directly understandable
by CPU
Advantages
● It is the only language that computer understands and executes without the
help of translator
● Very fast in execution
Disadvantages
● Difficult to write complex programs
● Can be prone to errors
● Less user friendly
● Takes a lot of time and difficult to modify
Assembly level language
● Compiler
● Assembler
● Interpreter
Compiler
● It is a program that converts entire source code or program codes into
machine level codes at once
● It generates error only after scanning the whole code
● Eg: C, C++, Java etc uses compiler to convert high level code to machine
level code
Assembler
● Assembler is used to convert assembly level code to machine level code
● The source program contains input of assembly level instructions
● It uses opcode for the instructions. An opcode basically gives information about the
particular instruction. The symbolic representation of the opcode (machine level
instruction) is called mnemonics.
Interpreter
● It takes high level code and translates into machine level code line by line.
● Takes less time to analyze the line code but the total time to analyze a whole
program increases
● Debugging is easier as the program will be continued only after the errors are
dealt with.
● Example: Python, Perl etc uses interpreter to convert program code into
machine code
Program Errors
● It is something in the program code that prevents a program from running and
compiling successfully.
● It is also known as bugs
● Logical Error
● Syntax Error
● Run time Error
Logical Error
● It occurs due to some error in logic while writing a program that leads to
undesired or wrong outputs
● But it does not terminate the program abnormally
● An example of a logical error would be dividing by 2.54 instead of multiplying
to convert inches to centimeters.
Syntax Error
● A syntax error is an error in the syntax of a sequence of characters or tokens
that is intended to be written in a particular programming language
● It is an error related to the grammar or specific syntax in which a code is to be
written.
● Examples of syntax errors are missing a comma or a quotation mark, or
misspelling a word
Run time error
● Runtime error refers to an error that takes place while executing a program
● These errors occur due to illegal operation performed in the program
● Memory leak
● Undefined object error
● Input Output Error
● Division by 0 error
Structured Programming
● It can be defined as a programming approach
in which the program is made as a single
structure
● It means that the code will execute the
instruction by instruction one after the other
● The instructions in this approach will be
executed in a serial and structured manner
Advantages of Structured Programming
● Easier to read and understand
● User Friendly
● Easier to Maintain
● Mainly problem based instead of being machine based
● Development is easier as it requires less effort and time
● Easier to Debug
● Machine-Independent, mostly.
Top Down approach
● In this approach we focus on breaking the big program into smaller program
● If the sub program is difficult, we further break it into smaller program
● This is mainly used in C, Fortran etc.
● Example:
Top Down Approach
Main Program
Sub Sub
Program Program
Object 4 Object 5
Main
Program
Bottom Up Approach
Problem Solving
Problem is defined as the difference between an existing situation and a desired
function, that is, in accordance with calculation
Solution is a desired situation and has the simplest form. If a problem is solved by
computing using machine called computer, then such process is called Problem
Solving.
First and foremost step of solving a problem is knowing about the nature of
problem in order to solve it. Almost all types of problems can be solved with
computer.
However, correct formulation of the problem in computer understandable terms is
essential to formulate the problem and solve it using computer.
Understanding of problems, Feasibility and Requirement Analysis
Problems can be of various nature and we need to understand about the problems first
to be able to solve it using computer.
Once the problem has been understood and we can solve it using computer the
feasibility of the problem solution needs to be determined.
We can solve a problem using various logic but what needs to be worked out is the most
feasible solution that can be derived with the least amount of complexities.
Another major portion to solving problems using computer is the analysis of the
requirements.
The solution to the problem can be solved however the requirements required is beyond
the possible technologies of today.
C, C++, Java, Python are the most popular programming language to develop
programs.
PHP and ASP remain a popular choice for developing web based applications.
Testing and Debugging
Once the program code has been written in a selected programming language of
choice the next task to complete is the testing and debugging.
Testing and debugging helps to find the problems associated with the program
behavior under normal and abnormal circumstances.
Extensive testing like white box testing and black box testing, integrationtesting
needs to done before the program is deployed into the real world scenario.
Implementation
After a program has been written and tested it needs to be implemented to the
target environment to solve the problem.
So a program must be well documented in order for the new people to understand
how the software was developed and how can it be modified.
The documentation start from the very beginning of the problem formulation to the
very end of the Evaluation and Maintenance.
Generation of Programming Languages
● First-generation languages (1GLs): These were the earliest programming
languages, also called machine languages, that directly corresponded to the
machine code that computers used to operate. They were low-level, difficult to
read and write, and machine-dependent.