Professional Documents
Culture Documents
Cs. M1
Cs. M1
MODULE-1
COMPUTER GENERATIONS
1. First Generation
2. Second Generation
3. Third Generation
4. Fourth Generation
5. Fifth Generation
1. First Generation:
The period of first generation computer is 1946-1959. And it is based on Vacuum
tube.
The first generation computers used vacuum tubes (Electric bulbs) as the basic
components for memory and CPU (Central Processing Unit).
These tubes produced a lot of heat and while doing the installations the tubes will
fuse frequently. So it is very expensive.
The Batch processing operating system was used.
It uses Punch cards, paper tape, and magnetic tape as input and output devices.
It uses machine code as the programming language.
2. Second Generation:
The period of second generation computer is 1959-1965. And it is based on
transistor.
It was cheaper, consumed less power, more compact in size, more reliable and faster
than the first generation machines made of vacuum tubes.
In this generation, magnetic cores were used as the primary memory and magnetic
tape and magnetic disks as secondary storage devices.
The computers used batch processing and multiprogramming operating system.
In this generation, assembly language and high-level programming languages like
FORTRAN, COBOL were used.
3. Third Generation:
The period of Third generation computer is 1965-1971. And it is based on
Integrated Circuit. A single IC has many transistors, resistors, and capacitors along
with the associated circuitry.
The IC was invented by Jack Kilby. This development made computers smaller in
size, reliable, and efficient.
It uses remote processing, time-sharing, and multiprogramming operating system.
It uses High-level languages (FORTRAN-II TO IV, COBOL, PASCAL PL/1, BASIC,
ALGOL-68 etc.).
4. Fourth Generation:
The period of fourth generation computer is 1971-1980. And it is based on Very
Large Scale Integrated (VLSI) Microprocessor.
VLSI circuits having about 5000 transistors and other circuit elements with their
associated circuits on a single chip.
COMPUTER TYPES
There are 4 types of computers:
1. Micro computer
2. Mini computer
3. Mainframe computer
4. Super computer
1. Micro computer:
Desktop computers, laptops, tablets and smart phones are called micro computers.
These computers are cheaper than other types of computers.
The micro computers are specially designed for general usage like entertainment,
education and work purposes.
Example: Laptops, PCs, Smartphones.
2. Mini computer:
Mini computers are used by small organizations and firms. The mini computers are
called as “midrange computers”.
These computers are not designed for a single user. One department of large
company or organizations use mini computers for specific purposes
Example: K-202, Texas Instrument TI-990, SDS-92, IBM Midrange Computers.
3. Mainframe Computer:
Mainframe is very large in size and is an expensive computer.
It is capable of supporting hundreds or even thousands of users simultaneously.
Mainframe executes many programs concurrently and supports many simultaneous
executions of programs.
Example: IBM4300, Hitachi’s Z800.
4. Super Computer:
Supercomputers are one of the fastest computers currently available.
Supercomputers are very expensive and are employed for specialized applications
such as data processing.
NASA uses super computers for launching space shuttles, controlling them and for
space exploration purpose.
COMPONENTS OF A COMPUTER
Input Unit:
This unit contains devices with the help of which we enter data into the computer.
This unit creates a link between the user and the computer.
The input devices translate the information into a form understandable by the
computer.
It is also known as internal storage unit or the main memory or the primary
storage or Random Access Memory (RAM).
Primary memory and secondary memory are two types of memories in the
computer.
All inputs and outputs are transmitted through the main memory.
3. Control Unit:
This unit controls the operations of all parts of the computer but does not
carry out any actual data processing operations.
It is responsible for controlling the transfer of data and instructions among
other units of a computer.
It obtains the instructions from the memory, interprets them, and directs the
operation of the computer.
It communicates with Input/Output devices for transfer of data or results
from storage.
It does not process or store data.
Output Unit:
The output unit consists of devices with the help of which we get the information
from the computer.
This unit is a link between the computer and the users.
Output devices translate the computer's output into a form understandable by the
users.
SOFTWARE AND ITS TYPES
Definition:
Software is a set of programs, which is designed to perform a well-defined function. A
program is a sequence of instructions written to solve a particular problem.
There are two types of software
i) System Software
ii) Application Software
i) System Software:
The system software is a collection of programs designed to operate, control and extend
the processing capabilities of the computer itself. System software is generally prepared by
the computer manufactures. These software products comprise of programs written in
low-level languages, which interact with the hardware at a very basic level. System
software serves as the interface between the hardware and the end users.
Example: Operating System, compilers, Interpreter and Assemblers.
ii) Application Software:
Application software products are designed to satisfy a particular need of a particular
environment. All software applications developed in Software Company can come under
the application software. Application software may consist of single or collection of
programs.
Keyboard
Mouse
Joy Stick
Light pen
Track Ball
Track Ball
Keyboard:
Keyboard is the most common and very popular input device which helps to input data to
the computer. Keyboards are of two sizes 84 keys or 101/102 keys, but now keyboards
with 104 keys or 108 keys are also available for Windows and Internet.
Typing Keys
1
These keys include the letter keys (A-Z) and digit keys (09) which
generally give the same layout as that of typewriters.
Numeric Keypad
It is used to enter the numeric data or cursor movement. Generally, it
2
consists of a set of 17 keys that are laid out in the same configuration
used by most adding machines and calculators.
Function Keys
The twelve function keys are present on the keyboard which are
3
arranged in a row at the top of the keyboard. Each function key has a
unique meaning and is used for some specific purpose.
Control keys
4 These keys provide cursor and screen control. It includes four
directional arrow keys. Control keys also include Home, End, Insert,
Mouse:
Mouse is the most popular pointing device. It is a very famous cursor-control device
having a small palm size box with a round ball at its base, which senses the movement of
the mouse and sends corresponding signals to the CPU when the mouse buttons are
pressed.
Generally, it has two buttons called the left and the right button and a wheel is present
between the buttons. A mouse can be used to control the position of the cursor on the
screen, but it cannot be used to enter text into the computer.
Joystick
Joystick is also a pointing device, which is used to move the cursor position on a monitor
screen. It is a stick having a spherical ball at its both lower and upper ends. The lower
spherical ball moves in a socket. The joystick can be moved in all four directions.
Light Pen
Light pen is a pointing device similar to a pen. It is used to select a displayed menu item or
draw pictures on the monitor screen. It consists of a photocell and an optical system
placed in a small tube. When the tip of a light pen is moved over the monitor screen and
the pen button is pressed, its photocell sensing element detects the screen location and
sends the corresponding signal to the CPU.
Track Ball
Track ball is an input device that is mostly used in notebook or laptop computer, instead
of a mouse. This is a ball which is half inserted and by moving fingers on the ball, the
pointer can be moved. Since the whole device is not moved, a track ball requires less space
than a mouse. A track ball comes in various shapes like a ball, a button, or a square.
Scanner
Scanner is an input device, which works more like a photocopy machine. It is used when
some information is available on paper and it is to be transferred to the hard disk of the
computer for further manipulation. Scanner captures images from the source which are
then converted into a digital form that can be stored on the disk. These images can be
edited before they are printed.
OPERATING SYSTEM
The Operating System is a program with the following features −
An operating system is a program that acts as an interface between the software and
the computer hardware.
It is an integrated set of specialized programs used to manage overall resources and
operations of the computer.
It is specialized software that controls and monitors the execution of all other programs
that reside in the computer, including application programs and other system software.
Objectives of Operating System
COMPUTER MEMORY
A memory is just like a human brain. It is used to store data and instructions.
Computer memory is the storage space in the computer, where data is to be
processed and instructions required for processing are stored.
The memory is divided into large number of small parts called cells.
Each location or cell has a unique address.
For example, if the computer has 64k words, then this memory unit has 64 * 1024 =
65536 memory locations. The address of these locations varies from 0 to 65535.
There are 3 types of memory
1. Cache Memory
2. Primary Memory
3. Secondary Memory
1. Cache Memory
Cache memory is a very high speed semiconductor memory which can speed up the
CPU.
It acts as a buffer between the CPU and the main memory.
It is used to hold those parts of data and program which are most frequently used by
the CPU.
The parts of data and programs are transferred from the disk to cache memory by
the operating system, from where the CPU can access them.
Advantages:
1. Cache memory is faster than main memory.
2. It consumes less access time as compared to main memory.
3. It stores the program that can be executed within a short period of time.
4. It stores data for temporary use.
Disadvantages:
1. Cache memory has limited capacity.
2. It is very expensive.
2. Primary Memory:
Primary memory holds only those data and instructions on which the computer is
currently working.
It has a limited capacity and data is lost when power is switched off.
It is generally made up of semiconductor device.
These memories are not as fast as registers.
The data and instruction required to be processed resides in the main memory.
It is divided into two subcategories RAM and ROM.
3. Secondary Memory:
This type of memory is also known as external memory or non-volatile. It is slower
than the main memory.
These are used for storing data/information permanently.
CPU directly does not access these memories, instead they are accessed via input-
output routines.
The contents of secondary memories are first transferred to the main memory, and
then the CPU can access it.
Example; disk, CD-ROM, DVD, etc.
INTRODUCTION to C LANGUAGE
C Language was designed and developed by Dennis Ritchie at BELL Laboratories in 1972. C
programming language is derived from earlier languages B, BCPL (Basic Combined
Programming Language) and CPL (Combined Programming Language).
ALGORITHM
An algorithm is a step by step procedure to solve a given problem. The good algorithm
should contain the following
Finite number of steps.
Each step should be clear and meaningful.
The input and output should be defined precisely.
An algorithm should not have computer code. ( C program)
Example 4: Write an algorithm to find sum and average of given three numbers.
Step 1: Start
Step 2: Declare variables a, b, c, sum and avg.
Step 3: Read values of a, b and c.
Step 4: Find the sum of a, b, c.
sum= a+b+c
Step 5: Find the average of a, b, c.
avg= sum/3;
Step 6: Display sum, avg.
Step 7: Stop.
Example 6: Write an algorithm to swap the two variables using third variable.
Step 1: Start
Step 2: Declare variables a and b.
Step 3: Read values of a and b.
Step 4: Exchange a & b
temp=a
a=b
b=temp
Documentation Section
Link Section
Definition Section
Global Declaration Section
main () function section
{
Declaration part;
Executable part;
}
Subprogram section
Function 1
Function 2
.
.
.
.
Function n
(i) Documentation Section
Documentation section consists of set of comment lines. This comment lines
indicate name of the program, author and other details.
(ii) Link Section
The Like section provides instruction to the compiler to link functions from the
system library such as using the #include directive.
(iii) Definition Section
The definition section defines all symbolic constants such as using the #define
directive.
(iv) Global declaration section
There are some variables that are used in more than one function such variables are
called global variables and are declared in the global declaration section. This section also
declares all the user-defined functions.
(v) Main() function Section
Every C program must have one main function section. This section contains two
parts:
a) Declaration Part:
The declaration part declares all the variables used in the executable part.
b) Executable part:
There is at least one statement in the executable part. These two parts must
appear between the opening and closing braces. The program execution begins
at the opening brace and ends at the closing brace. The closing brace of the main
function is the logical end of the program. All the statements in the declaration
and executable part end with a semicolon.
(vi) Subprogram section:
If the program is a multi function program then the subprogram section contains all
the user defined functions that are called in the main() function. User defined functions are
generally placed immediately after the main () function, although they may appear in any
order.
Example:
//Documentation section
/* Program Name: Sample Program
Author:aaa
*/
//Link section
#include <stdio.h>
// Definition Section
#define MAX_ARRAY_LENGTH 20
// Global declaration section
int max_input_length=15;
// Declaring user defined function
float addNumbers(float a, float b);
//Main() function section
int main()
{
int localvariable=50; //Declaration part
clrscr();
//Executable part
printf (“Max array length is %d\n”, MAX_ARRAY_LENGTH);
printf (“Max input length is %d\n”, max_input_length);
printf(Sum of 5.5 and 8.5=%f\n”, addNumbers(5.5,8.5));
return 0;
}
//defining an user defined function which has been declared.
float addNumbers(float a, float b)
{
return (a+b);
}
ALPHABET
The various categories of characters are used while writing a program is called alphabet.
The alphabet may be letter or digit or any special symbol. There are 96 symbols in C.
Example:
Letters A-X, a-z, both upper and lower
Digits 0-9
Symbols such as + - * / %
White spaces
C TOKENS
A token is a smallest or basic unit of a C program. One or more characters are grouped in
sequence to form meaningful words. These meaningful words are called tokens. C tokens
are classified as follows:
(i) Keywords
(ii) Identifiers
(iii) Constants
(iv) Operators
(v) Special symbols
(i) Keywords:
The words which have predefined meaning in C language are called keyword. And
this keywords are reserved for specific purpose in C language. They are also called
reserved words.
Example:
int, float, if, else, etc…
(ii) Identifiers:
Identifiers are the names given to program elements such as variables, constants,
function names, array names, etc.. It consists of sequence of one or more letters or digits
along with “_” (underscore). Rules to be followed to frame an identifier are:
The first character in the identifier should be a letter or “_” (underscore) and can be
followed by any number of letters or digits or underscores.
No extra symbols are allowed other than letters, digits and “_”.
The length of an identifier can be maximum of 31 characters for external names.
Such as function names and global variables.
The length of an identifier can be maximum of 63 characters for internal names such
as local variables.
Keywords cannot be used as identifiers.
Identifiers are case sensitive.
Example:
n, add, sum, sub
(iii) Constants:
Constants are values that will not change during execution of the program.
Constants are classified as
(a) Integer Constants
(b) Floating point constants
(c) Character constants
(d) String constants
(e) Enumeration constants
Example 2: 5.5 e3 [i.e: 5.5 x 103], 6.6 e-4 [i.e: 6.6 x 10-4]
Example:
enum days{sun, mon, tue, wed, thur, fri, sat};
Where
enum is keyword.
Days is variable name
sun, mon, tue, wed, thur, fri, sat are enumeration constants having value
0,1,2,3,4,5,6 respectively by default.
(iv) Operators
Operators are symbols which perform the operation such as addition, substraction, etc
between values or variables.
Example:
+,_,*,%,/
DECLARATION
What is variable?
Variable is an identifier whose value can be changed during execution of the
program. When we declare variable the memory location will be allocated based on data
type of that particular variable. We can store and manipulate values in that memory
location.
Declaration of the variable:
The declaration tells to the C compiler
- What is the name of the variable?
- What is the data type of the variable?
Initialization of the variable:
The variables can be initialized when it has been declared.
Syntax:
data type v1=value;
Example:
int m=10;
ASSIGNMENT STATEMENT
Assignment statement is used to assign the value for a given variable at any point of time in
the given program.
Syntax:
variable name= value (or) expression;
Example:
c=30;
c=a+b;
What is multiple assignment statement?
Multiple assignment statement is used to assign single value to more than one
variable at anytime and in a single statement.
Example:
a=b=30;
d=c=a+b;
DATATYPES
C data types are defined as the data storage format. The variable can store a data to
perform a specific operation. Data types are used to define a variable before to use in a
program. There are four data types in C language. They are,
OPERATORS
An operator is a symbol which helps the user to command the computer to do a certain
mathematical or logical manipulations.
1. Arithmetic operators
2. Relational Operators
3. Logical Operators
4. Assignment Operators
5. Increments and Decrement Operators
6. Conditional Operators
7. Bitwise Operators
8. Special Operators
1. Arithmetic Operators
The operators which are used to perform arithmetic operation such as addition,
subtraction, multiplication, division and modulus operation are called arithmetic operators.
The operator and meaning of the operator is shown below:
+ addition
- subtraction
* multiplication
/ division
% modulus
Example:
c=a+b;
d=e-f;
2. Relational Operators
Relational Operators are used to compare the relationship between operands and bring out
a decision.
Operators Example/Description
== x == y (x is equal to y)
!= x != y (x is not equal to y)
3. Logical Operators
These operators are used to perform logical operations on the given expressions and
produce the results.
There are 3 logical operators in C language. They are, logical AND (&&), logical OR (||)
and logical NOT (!).
Operators Example/Description
(x>=10)||(y>=10)
|| (logical It returns true when at-least one of the condition is
OR) true
!((x>5)&&(y<5))
It reverses the state of the operand “((x>5) &&
(y<5))”
! (logical If “((x>5) && (y<5))” is true, logical NOT operator
NOT) makes it false
4. Assignment Operators
In C programs, values for the variables are assigned using assignment operators.
For example, if the value “20” is to be assigned for the variable “sum”, it can be assigned
as “sum = 20;”
There are 2 categories of assignment operators in C language. They are,
Operators Example/Description
sum = 10;
= 10 is assigned to variable sum
sum += 10;
+= This is same as sum = sum + 10
sum -= 10;
-= This is same as sum = sum – 10
sum *= 10;
*= This is same as sum = sum * 10
sum /= 10;
/= This is same as sum = sum / 10
sum %= 10;
%= This is same as sum = sum % 10
sum&=10;
&= This is same as sum = sum & 10
sum ^= 10;
^= This is same as sum = sum ^ 10
6. Conditional Operators
Conditional operators return one value if condition is true and returns another value is
condition is false. This operator is also called as ternary operator.
Syntax : (Condition? true_value: false_value);
Example: (A > 500 ? 0 : 1);
In above example, if A is greater than 500, 0 is returned else 1 is returned. This is equal to if
else conditional statements.
7. Bitwise Operators
These operators are used to perform bit operations. First Decimal values are converted
into binary values which are the sequence of bits and bit wise operators work on these bits.
Bit wise operators in C language are
^ – XOR
<< – Left Shift
>> – Right Shift
Example:
Consider x=40 and y=80. Binary forms of these values are given below.
x = 00101000
y= 01010000
All bit wise operations for x and y are given below.
x&y = 00000000 (binary) = 0 (decimal)
x|y = 01111000 (binary) = 120 (decimal)
~x = 11111111111111111111111111
11111111111111111111111111111111010111 = -41 (decimal)
x^y = 01111000 (binary) = 120 (decimal)
x << 1 = 01010000 (binary) = 80 (decimal)
x >> 1 = 00010100 (binary) = 20 (decimal)
8. Special Operators
Below are some of the special operators that the C programming language offers.
Operators Description
C EXPRESSIONS
A sequence of operand and operators that reduces to a single value after evaluation
is called expression.
There are 5 types of expression in C language:
1. Arithmetic Expression
a. Single Mode Arithmetic Expression
b. Mixed Mode Arithmetic Expression
2. Relational Expression
3. Logical Expression
4. Assignment Expression
5. Short hand assignment expression
1. Arithmetic Expression:
Arithmetic expression is a combination of variables, arithmetic operators and
constants.
The arithmetic expression produces a single value when it evaluated.
Example: x + y
Where,
x and y are called operands
+ is called operator
There are 2 types of Arithmetic Expression
a. Single Mode Arithmetic Expression
b. Mixed Mode Arithmetic Expression
PROGRAMMING EXAMPLES
Hello world program:
//C hello world example
#include <stdio.h>
int main()
{
printf("Hello world\n");
return 0;
}
c = a + b;
int main()
{
int first, second, add, subtract, multiply;
float divide;
printf("Sum = %d\n",add);
printf("Difference = %d\n",subtract);
printf("Multiplication = %d\n",multiply);
printf("Division = %.2f\n",divide);
return 0;
}
#include <stdio.h>
int main()
{
int i=1;
while(i<10)
{
printf("%d ",i);
i++;
}
}
#include <stdio.h>
int main()
{
int i=20;
while(i>10)
{
printf("%d ",i);
i--;
}
}
Conditional Operator:
#include <stdio.h>
void main()
{
int a = 10, b = 11;
int c;
c = (a < b)? a : b;
printf(“%d”, c);
}
Bitwise AND
#include <stdio.h>
Void main()
{
int a=12, b=25;
printf(“Output=%d”, a&b);
}
Output:
Output=8