Followers

Thursday, December 20, 2007

GENERATIONS OF LANGUAGES

We know that computer is a dumb machine. It cannot do anything on its own. For getting any work done from the computer, you need to give instructions to the computer. These instructions are given in a language, which computer can understand. Just as we use some language to communicate with each other, you need some computer language to communicate with computer. There are different computer languages which are classified into Five Generations.

1GL or first-generation language is machine language. In this language the programs are written in the form of ‘0’ and ‘1’. 0 and 1 are the binary numbers which the computer understands. Machine languages are the only languages understood by computers directly. This language is Machine dependent. This means every CPU has its own unique machine language. Programs written on one computer may not run on another computer. Programs must be rewritten or recompiled, therefore, to run on different types of computers.

2GL or second-generation language is assembly language. This language uses mnemonics codes or symbols in place of 0’s and 1’s. A mnemonic is an alphabetical abbreviation used as a memory aid. A typical assembly instruction looks like this:

ADD 12,8

Since the computer can only understand machine language directly, an assembler converts the assembly language statements into machine language.
Assembly language is also machine-dependent and programming in this language is also very tedious.

1GL and 2GL are also known as “Low-Level Languages”.

3GL or third-generation language is a "high-level programming language”, such as PL/I, C, or Java. The disadvantage of the low level language led to the development of the high level languages. This is a programming language designed to be easier for a human to understand, including things like named variables. A typical instruction may look like:

let b = c + 2 * d

A compiler converts the statements of a specific high-level programming language into machine language. A 3GL language requires a considerable amount of programming knowledge.

4GL or fourth-generation language is designed to be closer to natural language than a 3GL language. Languages for accessing databases are often described as 4GLs. A 4GL language statement might look like this:

EXTRACT ALL CUSTOMERS WHERE "PREVIOUS PURCHASES" TOTAL MORE THAN $1000

5GL or fifth-generation language is designed to make the computer solve the problem for you whereas fourth-generation programming languages are designed to build specific programs. 5GL programming uses a visual or graphical development interface to create source language that is usually compiled with a 3GL or 4GL language compiler. Fifth-generation languages are used mainly in artificial intelligence research. Prolog, OPS5, and Mercury are the best known fifth-generation languages.

Wednesday, December 12, 2007

DATA REPRESENTATION

In digital systems like computers, quantities are represented by symbols called digits.
Various number systems being used in digital systems are:

1. Binary Number System

consists of two numbers: 0,1

2. Decimal Number System

consists of 10 numbers: 0 to 9

3. Octal Number System

consists of 8 numbers: 0 to 7

4. Hexadecimal Number System

consists of 16 numbers: 0 to 9 and A, B, C, D, E, F

A, B, C, D, E, F are the equivalents of number : 10, 11, 12, 13, 14, 15 respectively

IMPORTANT POINTS














  • Computer system understands only the binary system as all the components of the computer like transistors, switches, ports, etc. work on the two-state process of On and Off.




  • Decimal Number system is not conveneint to implement in digital systems as it is difficult to design an electronic equipment that can work with 10 different voltage levels.




  • Advantage of using Octal and Hexadecimal number systems is:

    a) easy to represent big numbers whereas representing big numbers in binary is complex.

    b) Decimal system is not used to represent big numbers because conversion from binary to octal and hexadecimal is simple as compared to conversion from binary to decimal and viceversa. Also the converison from binary to decimal is not accurate.








NUMBER CONVERSIONS


1. DECIMAL TO BINARY

Divide the integral part by the base number into which you want to convert till you get '0' as the quotient and write the remainders on the side.


Now move from bottom to top to write the remainders which is the binary equivalent of the integral number.


Multiply the fractional part with the base number into which you want to convert.
Write the integral value on the side and further multiply the fractional part by the base number into which you want to convert till you get '0' in the fraction.


Now move from top to bottom to write the integral values which are binary equivalent of the fractional part.


You may notice that in case of converting fractional part of Decimal system to Binary system, you may not get '0' in the final. So, you need to stop the multiplication process after 3 to 4 levels.


As a result Decimal to Binary conversion does not give you accurate results.



Example:

1. (15.25) to the base 10 into binary number.











Ans. (15.25) base 10 = (1111.01) base 2

2. (25.243) base 10 to base 2


Ans. (10001.00111) base 2












NOTE: You can see clearly in the example above that the conversion from Decimal to Binary is not accurate. For that matter even conversion from Decimal to Octal or Hexadecimal may not be accurate. This is one of the reasons for using Octal and Hexadecimal systems in Digital systems as the conversion from Decimal to Binary, Octal and Hexadecimal is not accurate.












2. DECIMAL TO OCTAL

The process of converting is the same given above for Decimal to Binary conversion. See the example below.








Example: (25.650) base 10 to base 8




Ans. (31.5146) base 8





3. DECIMAL TO HEXADECIMAL





The process of converting is the same given above for Decimal to Binary conversion. See the example below.

Example: (747.03125) base 10 to base 16












Ans. (2EB.08) base 16






4. BINARY TO DECIMAL





Pick the integer part and move in right to left direction, picking each element. Multiply each element with the base number from which you are converting to the power starting from '0' and increasing the power as you move from right to left.






Now pick the fractional part and move in left to right direction, picking each element. Multiply each element with the base number from which you are converting to the power starting from '-1' and increasing the power as you move from left to right.





Example: 11001.111 base 2 to base 10







Ans: 25.875 base 10







5. OCTAL TO DECIMAL





The conversion process remains the same as given above except that the digits will be multiplied by the base number of Octal 1.e. number 8.





Example: 352.51 base 8 to base 10








Ans. 234.64025 base 10






6. HEXADECIMAL TO DECIMAL






The conversion process is the same as above except that the digits will be multiplied by the number 16 i.e. base of the number to be converted.






Example: ABF.51 base 16 to base 10









Ans. 2752.31640625 base 10





7. BINARY TO OCTAL
Let us first write the Binary equivalents of Octal digits


0. 000



1. 001



2. 010


3. 011


4. 100


5. 101


6. 110


7. 111




NOTE: In Octal number system the numbers are to be represented in 3 bit form.



The process of conversion is as follows:





Pick the integer part and move from right to left making groups of 3. If the digits are less then add 0's to the left hand side.











Pick the fractional part and move from right to left and make groups of 3. If the digits are less then add 0's to the right hand side.











Now write the Octal value corresponding to the binary groups formed.





Example:

Ans: 26.24 base 8


8. BINARY TO HEXADECIMAL




Let us first write the Binary equivalents of Hexadecimal digits
0. 0000
1. 0001
2. 0010
3. 0011
4. 0100
5. 0101
6. 0110
7. 0111
8. 1000
9. 1001
10. ( A ) 1010
11. ( B ) 1011
12. ( C ) 1100
13. ( D ) 1101
14. ( E ) 1110
15. ( F ) 1111




NOTE: In Hexadecimal number system the numbers are to be represented in 4 bit form.
The process of conversion is as follows:




Pick the integer part and move from right to left making groups of 4. If the digits are less then add 0's to the left hand side.


Pick the fractional part and move from right to left and make groups of 4. If the digits are less then add 0's to the right hand side.


Now write the Hexadecimal value corresponding to the binary groups formed.
Example:

Ans: AE.5C base 16


9. OCTAL TO BINARY


Pick each digit from the number and Simply write the binary equivalent ( represented in 3 bit form ) of the digit given.

Example:





Ans. 101100011001.100111010 base 2




10. HEXADECIMAL TO BINARY


Pick each digit from the number and Simply write the binary equivalent ( represented in 4 bit form ) of the digit given.

Example:


Ans: 0 0 1 0 1 0 1 1 1 1 1 1 . 0 1 0 1 1 1 0 0 base 2


11. OCTAL TO HEXADECIMAL





12. HEXADECIMAL TO OCTAL





Saturday, December 8, 2007

GENERATIONS OF COMPUTER (on the basis of hardware developments)

FIRST GENERATION


TIME PERIOD : 1940's-1950's


TECHNOLOGY USED : Vacuum Tubes


SIZE AND SPEED : Huge, taking up entire rooms, Slow speed


LANGUAGE USED : Machine language


COST : System and working cost very high.


OTHER FEATURES : Used a great deal of electricity. Generated a lot of heat. Input was based on punched cards and paper tape, and output was displayed on printouts.


EXAMPLE : UNIVAC and ENIAC


SECOND GENERATION


TIME PERIOD : 1950's- 1960's


TECHNOLOGY USED : Transistors


SIZE AND SPEED : Lesser size and increased speed


LANGUAGE USED : Assembly language and languages like COBOL and FORTRAN


COST : Cost decreased


OTHER FEATURES : More efficient and reliable. Though the transistors still generated a great deal of heat that subjected the computer to damage, it was a vast improvement over the vacuum tube. Second-generation computers still relied on punched cards for input and printouts for output.


EXAMPLE : UNIVAC 1108, IBM 1401, CDC 1604


THIRD GENERATION


TIME PERIOD : late 1960's-1970's


TECHNOLOGY USED : Integrated Circuit


SIZE AND SPEED : Size Lesser and speed further increased


LANGUAGE USED : Operating System was developed.


COST : Cost decreased further


OTHER FEATURES : Instead of punched cards and printouts, users interacted with third generation computers through keyboards and monitors and interfaced with an operating system, which allowed the device to run many different applications at one time with a central program that monitored the memory. Computers for the first time became accessible to a mass audience because they were smaller and cheaper than their predecessors.


EXAMPLE : IBM-360 series, Honeywell Model 316, Honeywell – 6000 series, CDC – 1700.


FOURTH GENERATION


TIME PERIOD : 1970's-today


TECHNOLOGY USED : Microprocessor


SIZE AND SPEED : Reduced size and tremendous speed


LANGUAGE USED : High Level Languages like PASCAL, COBOL, C, C++, JAVA


COST : Reduced Cost


OTHER FEATURES : Microprocessors also moved out of the realm of desktop computers and into many areas of life as more and more everyday products began to use microprocessors. As these small computers became more powerful, they could be linked together to form networks, which eventually led to the development of the Internet. Fourth generation computers also saw the development of GUIs, the mouse and handheld devices.


EXAMPLE : Intel 4004, Apple Macintosh


FIFTH GENERATION


TIME PERIOD : 1990's -today


TECHNOLOGY USED : Microprocessor


SIZE AND SPEED : Reduced size and tremendous speed


LANGUAGE USED : Based on Artificial intelligence


COST : Reduced Cost


OTHER FEATURES : Fifth generation computing devices, based on artificial intelligence, are still in development, though there are some applications, such as voice recognition, that are being used today. The goal of fifth-generation computing is to develop devices that respond to natural language input and are capable of learning and self-organization.


EXAMPLE : Parallel Inference Machine

Note: Artificial Intelligence is the branch of computer science concerned with making computers behave like humans.

Note: Voice Recognition is the field of computer science that deals with designing computer systems that can recognize spoken words.

Thursday, December 6, 2007

DATA TYPES IN C++


Click on the link below to see the graphical display of different types of data types available in C++.

http://www.freemindshare.com/map/fkvw57BDHW/

Tuesday, December 4, 2007

OPERATORS AND EXPRESSIONS IN C++

The operations ( specific tasks ) are represented by Operators and the objects of the operation(s) are referred to as Operands.

There are different types of operators.


Click here to see a pictorical representation of types of operators:

http://freemindshare.com/map/GTZ4nyQCUJ/

1. Arithmetic Operators:

to do arithmetic operations.

+, -, *, /, % are arithmetic operators.

Example: 6+7=13, 12%5=2.

There are 2 types of Arithemetic Operators:

a) Unary Operators

operators that act on one operand.


+, -, are unary operators.


Example:


if x=12 then +x=12 and -x = -12


if x= -12 then + x = - 12 and - x= 12



b) Binary Operators


operators that act on two operands.


*, /, %, -


Example:


if a= 2 and b=5 hten


a+b=7


a*b=10


b-a= 3


b%a=1


5 - ( - 4)= 9



2. Increment and Decrement Operators

C++ includes two useful operators not generally found in other computer languages except C.


++ adds 1 to its operand


-- subtracts 1 to its operand


These operators come in two varieties: Postfix and Prefix version


3. Relational Operators


4. Logical Operators


5. Conditional Operators


6. Some other Operators
... to be completed

GETTING STARTED WITH C++


Click on the link below to see a graphical description of Character set and Tokens available in C++ language.
http://www.freemindshare.com/map/amru4GJLMP/

OPERATING SYSTEM


Click on the link below to see a graphical description of Functions and Types of Operating System.

http://www.freemindshare.com/map/bqsy3479DM/

Monday, December 3, 2007

GENERAL OOPS CONCEPTS

PROGRAMMING PARADIGM

Paradigm means the approach to programming that is the organising principle of a program.

There are different programming paradigms:

  • Procedural
  • Modular
  • Object Oriented

Procedural Programming:

  • Empasis is on doing things.
  • Data is not important.
  • Languages support this paradigm by providing facilities for passing arguments to functions (subprograms) and returing values from functions (subprograms).

Example: To desing an Inventory Control program for a departmental store which keeps records of inventory (stock) purchased and consumed. The following code shows the procedural approach to handle the problem.

int item_code; //unique identification code of the product.

char category[15]; //category to which it bleogs like grocery, decorative, home furnishings, toys, etc.

char date_of_selling[10]; // date of selling the product

float sale_price; // selling price of the product

int unit_left; // total no. of units left

char date_of_purchase[10]; // date of buying the product

float purchase_price; // purchasing price of the product

int unit_purchased; // total no. of units bought

purchase( ); // function defined to purchase a product

selling( ); // function defined to sell a product

Modular Programming:

  • Large program is broken into smaller units called functions (sub-programs)
  • An extension of procedural approach because it groups a number of functions and the data they manipulate into a larger entity called module.
  • The problem with this approach is that since many modules or functions access same data, the way data is being stored becomes important.

Example: The above program of Inventory control can be written in the following manner using Modular approach.

Common data

int item_code; //unique identification code of the product.

char category[15]; //category to which it bleogs like grocery, decorative, home furnishings, toys, etc.

Module Selling

char date_of_selling[10]; // date of selling the product

float sale_price; // selling price of the product

int unit_left; // total no. of units left

// The module may contain some more functions related to the process of selling

Module Purchasing

char date_of_purchase[10]; // date of buying the product

float purchase_price; // purchasing price of the product

int unit_purchased; // total no. of units bought

//The module may contain some more functions related to the process of purchasing

Object Oriented Programming:

  • Defines the real world entities.
  • Views the problem in terms of objects and classes involved rather than functions for doing it.
  • An object is an identifiable entity with some characteristics and behaviour.
  • Object can store data and has its interface through functions.
  • A class is a group of objects that share common properties and relationships.
  • An object is an instance of a class.
  • For example, if we have a class Car with the general characteristics of a car like: steering wheel, seats, a motor, brakes, etc. Opel Astra, SX4 will be the objects that belong to class Car.

Example: The above discussed problem of Inventory control can be dealt in the following manner according to the OOP approach.

Class Item

{

int item_code; //unique identification code of the product.

char category[15]; //category to which it bleogs like grocery, decorative, home furnishings, toys, etc.

char date_of_selling[10]; // date of selling the product

float sale_price; // selling price of the product

int unit_left; // total no. of units left

char date_of_purchase[10]; // date of buying the product

float purchase_price; // purchasing price of the product

int unit_purchased; // total no. of units bought

purchase( ); // function defined to purchase a product



selling( ); // function defined to sell a product

}

Now you can create objects of the class item which will include the common features of the class item and also have their own characteristics and behaviour.

The class item can have the following objects: Grocery, Decorative, Stationary, Toys, Home Furnishings, etc.

THE CONCEPTS OF OBJECT ORIENTED PROGRAMMING

1. DATA ABSTRACTION

  • refers to act of representing essential feaures without including the background details or explanations.
  • For example while driving the car you do not get into the internal details of wiring, motor working, etc. You just change the gears or apply the brakes etc.

Example: As in the above example, To sell or buy a product you simply choose the option buy or sell. The processing required behind is of no conern to the user.

2. ENCAPSULATION

  • Combines data and functions that operate on that data into a single unit.
  • Wrapping up of data and functions (that operate on the data) into a single unit (called class) is known as encapsulation
  • Data is hidden and safe from alteration.
  • For example, while designing the car, the data i.e. steering wheel, acceleerator, brake, clutch, etc. and the process of moving a car forward, moving car backward, etc. are wrapped into a single unit called class. The user is just using the processes and are not bothered about the working of the process.
  • Thus, Encapsulation is a way to implement Data Abstraction.

Example: In the above example, the in-charges of different categories of items do not have access to data of the other category. Item is a class and Grocery, Decorative, Toys, etc. are the objects (instance) of a class.

3. MODULARITY

  • Partitioning the program into individual components is called Modularity.
  • Program is decomposed into set of cohesive (organised) and loosely coupled (less interdependent) modules.
  • Modularity in C++ is implemented through seperate compiled files.
    Module interface is placed in the header files.
  • For example, to design a music system it vcan be decomposed into the following modules: Speakers, CD-player, FM-player, Recorder, etc.

Example: in the above example of inventory control, we can have modules like Selling, Buying, Exchange of product, etc.

4. INHERITANCE

  • It is the capability of one class of things to inherit the capabilites or properties from another class.
  • Each class inherits the properties of one class and also add some of its own properties.
  • For example, the class 'Car' inherits the properties from the class 'Automobiles' which inherits some of its properties from another class 'Vehicles'.

WHY INHERITANCE?

1. Ensures closeness to real world.

2. Provides reusability. For example to extend a project, you can use the already created classes to inherit their properties and add their own properties at the same time.

3. Inheritance is transitive i.e. if class 'Car' inherits the properties of class 'Automobiles' and it further inherits the properties of class 'Vehicles ' then class 'Car' automatically inherits the properties of class 'Vehicle'.

Example: In the Inventory control example, if the need arises to expand the software. The programmer can simply inherit the properties of the class item if required.

5. POLYMORPHISM

  • A key feature of OOP language.
  • Languages that do not support polymorphism cannot be called as Object Oriented languages.
  • Languages that support Classes but not Polymorphism are Object Based languages.
  • It is the ability for a message or data to be processed in more than one form.
  • For example, the class 'Shape' has the function 'area()'. The objects of the class are like Triangle, Circle, Rectangle. When the function 'area()' is called by each of these objects, it behaves in a different way. Area of Triangle, Circle, Rectangle will be calculated respectively.

Saturday, December 1, 2007

BASIC CONCEPTS OF COMPUTER


DEFINITION OF COMPUTER
Computer is an:

  • electronic device
  • accepts and stores input
  • manipulates it
  • outputs result
  • under the direction of stored programs and instructions

DATA AND INFORMATION

Data is raw facts and figures.

When data is processed to make it meaningful it becomes Information.

Example:

Data: India, 200, 4, cricket, wicket

Information: India beats Pakistan in cricket match by 50 runs.

WHAT IS HARDWARE

Hardware refers to physical and tangible (touchable) components of computer.

Example: CPU, Keyboard, Monitor, Mouse, Printer

WHAT IS SOFTWARE

Software is a set of programs which make the hardware of the computer work. Software is abstract in nature that is it cannot be felt and touched.

Computer is a dumb machine without the software.

A computer needs to be instructed to perform and give output.

The set of these instructions is known as a Program.

Example: MS Paint, Corel Draw, Notepad, etc.

TYPES OF SOFTWARE




  • APPLICATION SOFTWARE

set of programs necessary to carry out operations for a specified application.

  1. PACKAGES: they are general application software. Most common categories are:
    a) Word Processing Software: e.g. MS Word, Wordstar, etc.
    b) Spreadsheets: e.g. MS Excel, Lotus 123, etc.
    c) Database Management Systems (DBMS): e.g. Foxpro, MS Access, Oracle, etc. d) Desktop Publishing Packages (DTP): e.g. CorelDraw, Powerpoint, etc.
  2. UTILITIES:are those application programs that assist the computer by perfrorming housekeeping functions like backing up disk or scanning/clearing viruses. Some of the utilities are: Text editor, backup utility, Compression utility, Antivirus software.
  3. CUSTOMISED SOFTWARE: tailor made software according to users needs.
SYSTEM SOFTWARE

System software controls the internal functioning of the computer.

  1. OPERATING SYSTEM:
    software which acts as an interface between the user and the hardware.

    Note: refer to the post about Generations of computer languages for a better understanding of the text given below.
  2. LANGUAGE PROCESSOR:
    software which converts High Level Language (HLL) into Machine language. There are three types of language processers.

a) Assembler: converts program written in Assembly language into machine language.

b) Compiler:

1) converts program written in HLL to machine language in one go.

2) after the compilation compiler is removed from the memory.

c) Interpreter:
1) converts the program written in HLL into machine language line by line.

2) It is resident in the memory till the entire conversion takes place. Therefore, unnecessary usage of memory.