C-Programming

Unit-1
Computer Fundamental

Computer:
The word “Computer” is derived from the Latin word “Computare” which means to calculate. Hence, computer is normally considered as a calculating device, which performs the entire task at very fast rate. A computer is an electronic machine that accepts data and instructions, stores it until the data is needed, processes large amount of data according to the instructions provided by the user, and finally returns the results to the user

Advantages of computer:
- Computer is a very fast machine.
- Computers operate with almost 100% accuracy.
- Computer is capable of doing required task again and again without any difficulty.
- Computers have capability of storing huge amount of data.
- Computers can perform variety of jobs.
Disadvantages of computer:
- Computer is an automatic device, even it requires operator to operate the computer.
- Computer is very expensive in comparison to other electronic devices, so every people cannot afford it.
- Computer cannot think itself to give decisions.
- Computer requires technical person for maintenance if it does not work properly.
Types of computers:

Analog computer & Digital computer

Analog computer

The computer which can process analog quantities (continuous data) is called an analog computer. They are designed to accept physical quantities such as temperature, pressure, speedometer, etc and record them as readings along a continuous scale.
Examples of analog devices are: thermometer, speedometer, etc.

Features of analog computer:

- These computers work on the derived quantities as temperature, speed, voltage, etc.
- They take only one instruction at a time, execute it, give us the result and take next instruction.
- To use these computer knowledge of programming is not required.
- They do not perform any calculation.

Digital computer

The computer which accepts discrete data (discontinuous data) is known as digital computer. The digital computers operate by counting numbers, or in other words, it represents information in discrete form. It operates directly on numbers expressed in binary number system. Digital computers are more accurate than analog computer, since there is no analogous representation.

Features of digital computers

- These computers only operate on digit and they are 0 & 1.
- Digital computers do calculation to give us results.
- A digital computer takes all the instruction together and then execute one by one.
- To use these computers knowledge of programming is essential.

Software
A set of instructions give to the computer in machine code that tells the computer what to do and how to perform the given task of the user is known as computer software. The main objective of software is to enhance the performance capability of hardware. Examples: Windows XP, MS- Word, MS-Excel, etc.

Type of Software

System software/ Application software

System Software

It is a collection of program, language, etc which allows the user to communicate with computer equipments, the software makes the machine easier to use and make efficient use of resources of hardware. It is like a layer which acts as interface between computer and application software. It is used in almost all kinds of computer like mainframe, mini or micro computer.

Types of system software

Operating system/ Translating Program/ System support software/ utility software

Application software

Application software is prepared and supplied by software company and computer manufacturer. Application software is a subclass of computer software that employs the capabilities of computer directly to a task that user wishes to perform. Application software are designed to process data and support users in an organization such as solving equations or producing bills, result processing of Pokhara university, etc.

Types of application software

Tailored package/ Packaged software

Tailored package

Tailored software is the software, which are specially designed and developed to solve a specific or particular task. The nature of processing of data seems similar but actually they are different in many ways. High-level language such as COBOL, BASIC, FORTRAN, PASCAL, C, etc. is used to prepare tailored software. Examples: salary sheet, sales ledger, payroll system, library management, etc.

Packaged software

Packaged software is the software which is generalized a set of programs and developed for general purpose. These programs are user friendly and designed for use in more than one environment. Examples: Word processing packages: MS- Word, MS-Star etc. Spreadsheet: Excel, Lotus, etc. Graphics: Photoshop, 3D studio max, etc. DBMS Package: Dbase III, Oracle, etc.

WHAT IS Programming LANGUAGE?
Language is a collection of words and symbols which can be used to perform certain task or activities and to establish a communication between person to person. In the same manner computer languages are the collection of predefine key words which can be used to perform certain task and to communicate between two entities like between two machines or between human and computers or computers and others peripherals. A programming language is the series of commands written by programmer in a systematic order which can perform work easily in higher speed. A programming language is the platform which provides the environment to write program. Actually programming language have their own set of grammatical rules used to write program. Without programming language program is useless. Examples: C, C++, COBOL, Pascal, etc.

There are three different levels of programming languages. They are:
Machine languages (low level)/ Assembly languages/ High-level language

Machine Level Languages (MLL) :-

Computers are made of No. of electronic components and they all are two – state electronic components means they understand only the 0 – (pulse) and 1 (non – pulse). Therefore the instruction given to the computer must be written using binary numbers. 1and 0. Computers do not understand English or any other language but they only understand or respond to binary numbers(0 and 1). So each computer has its own Machine languages.

Advantages:

1. Time taken to execute program is less.
2. The program written in this language need not to be translated.

Disadvantages:

1. Difficult to learn.
2. The knowledge of internal architecture is essential for program coding.

Assembly Level Languages (ALL) :-

In assembly language instruction are given in English like words ,such as MOV,ADD,SOB etc. Hence it is easy to write and understood assembly language. As we know computer can understand only machine level language . Hence assembly language program must be translated into machine level language. The translator which is used for translating is called “assembler”.

Advantages:

1. Assembly language is easier to understand as compared to machine language.
2. Easier for program debugging.

Disadvantages:

1. It is machine dependent.
2. Program written in assembly language is comparatively larger.

High level language:-

It is designed keeping in mind the features of portability means these language are machine independent. These are the English like language, so it is easy to write and understand the programs of high level language. For translating high level language program into machine language we used “compiler” and “Interpreter” are used. The language in this category is:- FORTAN,COBOL,C,C++,etc.

Advantages:

1. They are easier to learn as compared to assembly and machine language.
2. Lower program preparation cost.
3. Machine independent.

Disadvantage:

1. Require more time and memory to execute.

WHAT IS LANGUAGE TRANSLATORS?
As we know computer can understand only machine level language ,which is in binary 0 or 1 form . Which is difficult to write and maintain the program of machine level language. So the need arises for converting the code of high level and low level languages into machine level language, so the translator are used to achieve this process.

Type of Translator

Assembler/ Compiler/ Interpreter

Assembler

It is used for converting the code of assembly language into machine level language. This translation is done with the help of a translator program called assembler. Assembler is a system software supplied by computer manufacturers.

Compiler

It is used for converting the code of high level language into machine level. The compiler searches all the errors of program and lists them. A Compiler checks the entire program written by user and if it is free from error and mistakes then produces a complete program in Machine language known as object program.

Interpreter

The work of interpreter is same as compiler. It is also used for converting high level language program into machine level language but it checks the errors of program statement by statement .

Differences between Compiler & Interpreter

Error finding:

Error finding is much easier in Interpreter because it checks and executes each statement at a time. So wherever it fine some error it will stop the execution. Where Compiler first checks all the statement for error and provide lists of all the errors in the program.

Time:

Interpreter takes more time for the execution of a program compared to Compilers because it translates and executes each statement one by one. Examples: C, C++, FORTRAN, etc are compiler whereas BASIC, LISP, etc are interpreter.


Download the pdf to get all the unit wise notes.
Try to save your valueable time!