Computer Basics and Operating Systems Guide
Computer Basics and Operating Systems Guide
Module-1
C- Commonly
O-Operating
M-Machin
P-Particularly
U-Used for
T-Technical and
E-Educational
R-Research
Computer: Computer is an electronic device which takes data and instructions as input from the
user, processes the data and provides useful information known as output.
There are two major components of a computer system-
Hardware
Software
Hardware: The physical components of a computer system are known as hardware. The hardware
components of a computer system consist of five parts- input devices, central processing unit (CPU),
primary memory, secondary memory and output devices.
Block Diagram of Computer System or John Von Neumann Architecture:
Input Device: An input device is any device which is used to provide data and control signals to a
computer system. Examples of input devices are- keyboard, mouse, scanner, light pan, joystick etc.
[Author Name] 1
CCSE0151
Output Device: An output device is any device which is used to display the data to the user either in
the form of hard copy or soft copy. Example of output devices are- Monitor, printer, speaker etc.
Central Processing Unit (CPU): The arithmetic logical unit (ALU) and control unit (CU) of a
computer system are jointly known as Central Processing Unit. It also contains its internal memory
known as CPU registers. CPU is also known as Processor.
The CPU is also responsible for executing instructions such as arithmetic calculations,
comparison among data and movement of data inside the system. All work that is done on computer
is performed directly or indirectly by the CPU.
i. Arithmetic Logical Unit (ALU): The actual processing of data and instructions are performed
by ALU. The major operations performed by ALU are- addition, subtraction, multiplication,
division, logic and comparison.
ii. Control Unit (CU): The control unit is responsible for coordinating different operations using
time signals. The control unit determines the sequence in which different instructions in a
computer system are executed.
iii. CPU registers: The CPU registers are used to store the data to be processed by the CPU and
the processed data. Examples of CPU register are- accumulator, general purpose register.
Accumulator: Accumulator is a register in which intermediate arithmetic and logic
results are stored.
General Purpose Registers(GPRs): General-purpose registers can store both data
and addresses, i.e., they are combined data/address registers.
Memory Unit: The memory unit is used to store the data and instructions in a computer system.
There are basically two types of memories-
Primary Memory
Secondary Memory
Primary Memory: Primary memory is the memory that is directly accessed by the CPU. It is also
known as main memory. It stores the data that is currently in use by the CPU. There are three major
types of primary memories-
Random Access Memory (RAM): It is a read/write memory. It is a volatile memory. It stores the data
as long as the computer system is switched ON. There are two types of RAM.
SRAM: SRAM stores the data as long as the power supply is ON. These are costly and faster
as compared to DRAM.
DRAM: DRAM stores the data for very short time. It loses its data even power supply is ON.
These are cheaper and slower as compared to SRAM.
[Author Name] 2
CCSE0151
ROM: ROM is a read-only memory. It is non-volatile memory; it means is stores the data even power
supply is switched off. Its data cannot be modified by the end user.
It contains the manufacturer’s instructions and information. It also contains a software
known as boot program.
Cache Memory: This is the fastest primary memory. It is used to store frequently used data. It also
stores the data and applications that was last processed by the CPU. When the processor performs
the processing, it first searches the cache memory and then the RAM for an instruction.
Secondary Memory: The memory that is not directly connected with the CPU is known as secondary
memory. The secondary memory is used to store the data that is currently not in use. It is used to
store the data permanently. There are two types of secondary memory.
Magnetic Storage Devices: The magnetic storage devices store the information that can be
read, erased and rewritten many times. Examples are- hard disk, floppy disk etc.
Optical Storage Devices: The optical storage devices use laser beams to read and write data.
Examples are- CD-ROM (Compact Disk Read Only Memory), CD-RW (Rewritable Compact
Disk), DVD (Digital Versatile Disk).
1. Primary memory can be volatile or non- 1. Secondary memory is always non- volatile
volatile. memory.
2. It is directly accessed by the CPU. 2. It is not directly accessed by the CPU.
3. It is costly as compared to secondary 3. It is cheaper as compared to primary
memory. memory.
4. It is also known as internal memory. 4. It is also known as external memory.
5. It is fast to interact with CPU. 5. It is slow to interact with CPU.
Memory Hierarchy: The hierarchy in which memories are present in respect of the connection
with CPU is known as memory hierarchy.
[Author Name] 3
CCSE0151
Software: Software is a set of instructions that allow the user to interact with computer, its
hardware, or perform task. Software provides the instructions to computer system what to do and
how to do. There are two major categories of software-
i. System Software
ii. Application Software
i. System Software: System software is a computer software which is used to operate and control
the computer hardware and to provide a platform for running application software. It can directly
interact with the computer hardware. Examples of system software are- operating system, boot
program, compiler and other computer maintenance software.
ii. Application Software: Application software is a software which is used to perform a specific task.
It cannot run without system software. It cannot directly interact with computer hardware.
Examples are- MS Word, Internet Explorer, Adobe Photoshop etc.
[Author Name] 4
CCSE0151
1. It can directly interact with computer 1. It cannot directly interact with computer
hardware. hardware.
2. It is used to manage and control the 2. It is used to perform a specified task and it
computer system. cannot run without system software.
3. It is difficult to develop. 3. It is easy to develop.
4. Examples: Operating System, Compiler. 4. Examples: MS Word, Web Browser.
Characteristics of Computer System: The following are the main characteristics of computer
system-
1. Speed: The speed of computer system is very high. It can perform millions of instructions per
second.
2. Accuracy: The degree of accuracy of computer system is very high and every calculation is
performed with the same accuracy. The errors in computers are due to human and inaccurate
data.
3. Memory: Computer has the power of storing any amount of data as long as you require it.
4. No IQ (Intelligence Quotient): Computer is a dumb machine. It cannot do any work without
instructions from user.
5. Diligence (Hard worker): A computer is free from tiredness. It can work for hours without
creating any error.
6. No Feelings: Computer does not have feelings, emotions, taste, knowledge, experience etc.
Thus, it does not get tired even long hours of work.
Application areas of Computer (Use of Computer): The following are the main application areas
of Computer-
1. Education: Computers are used in teaching and research. The students can solve different kinds
of problems quickly and efficiently by using computers. They can also collect different
information on the Internet.
2. Business: Many business activities are performed very quickly and efficiently by using
computers. The paperwork is also reduced by using computers. Many business use websites to
sell their products.
3. Health and Medicine: In medical field computers are used for maintaining patient history &
other records. They are used to calculate the risk of a disease. They are also used to develop new
medicine.
4. Entertainment: Computers are used to watch movies, listen music and play games. These are
also used to watch television programs on the Internet. Computers are also used to add special
effects in movies.
5. Defence: In defence computers are used to develop missiles and other equipment in the
deference system. Computers are also used for controlling the functioning of weapons like
tanks, ships, guns, missiles etc.
[Author Name] 5
CCSE0151
6. Sports: In sports computers are used for training, recording information, scoreboard, safety
equipment design etc.
2. Technology used: Depending on the functionality and technology used there are three types of
computers.
(a). Digital Computer: A digital computer is used to store and process the data in terms of digits
i.e. 0 and 1. In digital computer letters, words and text are represented digitally.
(b). Analog Computer: Analog computers are used to carry out operations on data which can
vary continuously and are measurable rather than countable such as time, length, weight
etc.
(c). Hybrid Computer: The computer which have the capabilities of both digital and analog
computer is known as hybrid computer.
[Author Name] 6
CCSE0151
operations. They could solve only one problem at a time. The main feature of first
generation computers are- vacuum tubes, supported machine language only, slow
input/output, generate lot of heat, costly, huge, need of AC, non-portable. Examples are-
ENIAC, UNIVAC etc.
(b). Second Generation (1956-1963) Transistor: The second-generation computer used
transistors for making circuit of CPU. They were smaller, faster, cheaper and more energy
efficient than the first generation. They used punched cards for input and output was
displayed on printouts. Second generation computers supported machine and assembly
language. Examples are- IBM 1620, CDC3600 etc.
(c). Third Generation (1964-1971) Integrated Circuits: The third-generation computers used
integrated circuits for making circuit of CPU. In this generation keyboard and monitor were
used for input and output. These computers were smaller and cheaper than the previous
generations. These computers supported high level languages. Examples are- IBM 360
series, IBM 370 series etc.
(d). Fourth Generation (1971 to present) VLSI & Microprocessor: In fourth-generation VLSI
(Very Large Scale Integration) technology used. Fourth generation computers were very
small and powerful. In this generation microprocessor is used as CPU. In microprocessor
thousands of silicon chips were built onto a single silicon chip. The concept of internet was
introduced in this generation. These computers also used pointing devices for input.
(e). Fifth Generation (Present and Beyond) ULSI & Artificial Intelligence: In fifth-generation ULSI
(Ultra Large Scale Integration) technology used. Fifth generation computing devices are
based on artificial intelligence. They are in development phase. The goal of fifth generation
computing is to develop devices that respond to natural language input and capable of
learning.
Operating System: An operating system is a system software that provide an interface between
application software and computer hardware. It provides a platform for running the application
software. It is also responsible for managing the resources of a computer system. It also provides
some basic level of security.
Functions/ services/ need/ goals of operating system: An operating system provides a large
amount of services. Some functions of operating system are-
[Author Name] 7
CCSE0151
(a). Process Management: A program in execution is known as process. The operating system is
responsible for allocation and deallocation of processes to the processor.
(b). Primary memory management: An operating system is responsible for allocation and
deallocation of memory. It decides which data will store where.
(c). Secondary memory management: An operating system handles the communication of
primary memory with secondary memory. It also handles the storage of data on the
secondary memory.
(d). Input/ Output device management: An operating system allocates and deallocates the
devices to a process.
(e). File management: An operating system keeps the record of files in use and the processes
(programs) using these files. It also provides the permission to access these files.
(f). Security: An operating system provides security and protection to the computer system.
(g). User interface: An operating system provides an interface by using which a user interacts
with computer system.
Types of Operating System: Depending on the characteristics of operating system there are
following types of operating system.
(a). Single User Operating System: A single user operating system allows only one user at a time
to use a computer system. Examples are- MS-DOS, Windows XP.
(b). Multiuser Operating System: A multiuser operating system allows more than one user to
use a computer system at the same time or different times. Examples are- Linux, Windows
2000.
(c). Multitasking Operating System: A multitasking operating system allows more than one
program to run at the same time. A user can perform different task such as print a
document, copy files etc. at the same time. Examples are- Windows XP, Linux.
(d). Multithreading Operating System: A multithreading operating system allows the running of
different parts of a program at the same time. Examples are- UNIX, Linux.
(e). Time sharing Operating System: Time sharing system allows many users to share the
computer resources simultaneously. In other words, time sharing refers to the allocation of
computer resources in time slots to several programs simultaneously.
Depending on the interface provided by the Operating Systems there are two types of OS-
(a). Graphical user interface (GUI): A graphical user interface operating system allows users to
interact with computer system using graphical icons, rather than text commands. A GUI
represents the information and actions to a user through graphical icons. These types of
operating systems are easy to operate.
(b). Command line user interface (CUI): A command line user interface operating system allows
users to interact with computer system using text commands. A command line interface
provides a powerful means to control a program.
Disk Operating System (DOS): DOS stands for Disk operating system. It is CUI (Command
User Interface). It was written by Tim Paterson and introduced by Microsoft in August 1981. It is a
single user, single tasking operating system.
There are two types of DOS commands-
Internal DOS Commands
[Author Name] 8
CCSE0151
Linux Operating System: Linux is a multiuser multitasking operating system. It was developed
by Linus Torvalds in 1991. It is an open source operating system, which means any programmer can
download it from internet for free and modify it.
Following are some of the important features of Linux Operating System-
Portable
Open Source
Multi-User
Multiprogramming
Secure
Layers of Linux Operating System:
Users
Shell and System Utilities
System Libraries
Kernel
Hardware
Kernel: Kernel is the core of Linux Operating System. It is responsible for all major activities such as
memory management, process management, Input/output management etc. It directly Interacts
with the hardware.
System Libraries: System libraries are the special functions by using which the shell or system
utilities access the kernel’s features.
Shell and System Utilities: Shell is an interface between the user and the kernel. It is a command
interpreter. System utilities are application programs used by the user for doing specified task.
Android operating system: An open source Linux-based operating system intended for
mobile computing platforms It includes a Java API for developing applications. It is developed by
GOOGLE.
Some of the characteristic feature of android operating system are-
Linux based operating system
Designed primarily for touch screen mobiles
Open-source operating system
Allows the software to be freely modified
Android applications can be downloaded from Google play Store
Requires low cost for development
Architecture of Android Operating System:
[Author Name] 9
CCSE0151
Applications
Application Framework
Libraries Android Runtime
Linux Kernel
Linux Kernel: The bottom most layer of Android operating system is Linux Kernel. It interacts with
hardware and provides basic services such as memory management, process management etc.
Libraries: The libraries are written in C and C++ language. By using these libraries, the application
framework access the kernels features. Some libraries include-
Surface Manager
Media Framework
SQLite
WebKit
Android Runtime: It is the third section of the architecture and is present in the second layer from
the bottom. It consists of core libraries and Dalvik Virtual Machine. Dalvik Virtual Machine is a kind
of Java Virtual Machine specially designed and optimized for low processing power and low memory
environments.
Application Framework: This layer provides the interface with which the applications directly
interact. The major components of application framework layer are-
Activity manager
Window manager
Content providers
Telephony manager
Resource manager
Location manager
Applications: Applications layer is the topmost layer in the architecture and consist of various
applications such as web browsers, sms client applications, media players etc.
Windows Operating System: Microsoft Windows is the name of several families of GUI
(Graphical User Interface) operating systems by Microsoft. Microsoft first introduced an operating
system environment named windows in November 1985 in response to the growing interest in
graphical user interface (GUIs).
Number System: A number system is a set of mathematical symbols and rules that are used to
represent numbers in a consistent manner.
1
[Author Name]
0
CCSE0151
Decimal 10 0, 1, … 9 Yes No
Binary 2 0, 1 No Yes
Octal 8 0, 1, … 7 No No
Hexadecimal 16 0, 1, … 9, A, B, … F No No
Number representation:
Decimal Binary Octal Hexadecimal
0 0 0 0
1 1 1 1
2 10 2 2
3 11 3 3
4 100 4 4
5 101 5 5
6 110 6 6
7 111 7 7
8 100 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
Decimal Octal
Hexadecimal
Binary
1. Decimal to binary number conversion
Divide the decimal number by two
Write the remainder on the right and quotient below the decimal number
Repeat until the decimal number has reached zero
Note the final Binary value from bottom to up
Example: (125)10 = (?)2
1
[Author Name]
1
CCSE0151
Solution:
(143)10 = (217)8
Decimal fraction to Octal conversion
The fractional part of the given decimal number is multiplied by 8
The product obtained has an integer part and fractional part, the integer part here is also
referred as carry
1
[Author Name]
2
CCSE0151
The carry that we obtain at each multiplication iteration becomes a digit in the fractional
binary number
The fractional part obtained is again multiplied and the process is repeated until the
fractional part becomes zero or the number of multiplication iteration equals the number of
significant digits after the decimal point
The carry that we obtain at each stage are taken from first iteration to the last iteration to
form the numerals in the fractional binary number
Example: (0.40)10 = (?)8
0.40 x 8 = 3.20 3
0.20 x 8 = 1.60 1
0.60 x 8 = 4.80 4
0.80 x 8 = 6.40 6
0.40 x 8 = 3.20 3
(0.40)10 = (0.31463)8
(2250)10 = (8CA)16
Decimal fraction to Hexadecimal conversion
The fractional part of the given decimal number is multiplied by 16
The product obtained has an integer part and fractional part, the integer part here is also
referred as carry
The carry that we obtain at each multiplication iteration becomes a digit in the fractional
binary number
The fractional part obtained is again multiplied and the process is repeated until the
fractional part becomes zero or the number of multiplication iteration equals the number of
significant digits after the decimal point
The carry that we obtain at each stage are taken from first iteration to the last iteration to
form the numerals in the fractional binary number
1
[Author Name]
3
CCSE0151
Solution:
= (0×20). (0 ×2-1) + (1× 2-2) + (0×2-3) + (1×2-4)
= (0.375)10
1
[Author Name]
4
CCSE0151
Solution:
(ABC)16 = (2748 )2
Octal Digit 0 1 2 3 4 5 6 7
Binary Equivalent 000 001 010 011 100 101 110 111
Solution:
4 7 2 (100111010)2 = (472)8
1
[Author Name]
5
CCSE0151
Solution: 1 0 A F
2 B B (1010111011)2 = (2BB)16
Solution:
Solution:
1
[Author Name]
6
CCSE0151
BCD Code: In BCD code, each decimal digit is represented by four-bit binary code.
Gray Code: Gray code is a numerical code used in computing in which consecutive integers are
represented by binary numbers differing in only one digit. It is a binary numeral system where two
successive values differ in only one bit.
ASCII Code (American Standard Code for Information Interchange): In
computers, Character data is represented by using standardized numeric codes which have been
developed. The most widely accepted code is called the American Standard Code for Information
Interchange (ASCII). The ASCII code associates an integer value for each symbol in the character set,
such as letters, digits, punctuation marks, special characters, and control characters. For example the
ASCII value of A is 65.
1
[Author Name]
7
CCSE0151
1
[Author Name]
8
CCSE0151
Advantages:
(i). High level language programs are much easier to understand.
(ii). High level language programs are portable.
(iii).Instructions are much easier to remember and use.
(iv).Fewer instructions are required to write a program.
(v). It is easy to debug high level language program.
(vi).A program can usually be developed much more quickly using a high level language.
Disadvantage:
(i). High-level language programs take up more space and execute more slowly.
Types of High Level Languages: There are three types of high level languages.
(a). Procedure Oriented Languages (Third Generation Language or 3GL): High level
programming languages designed to solve general purpose problems are known as
third generation languages. 3GLs are much more machine independent and more
programmer-friendly. Names of 3GLs are- C, C++, C#, Java etc.
(b). Problem Oriented Languages (Fourth Generation Language or 4GL): High level
programming languages designed for specific domain are known as fourth
generation languages. 4GLs are designed to reduce the overall time, effort and cost
of software development. The main domains and families of 4GLs are: database
queries, data manipulation, and mathematical optimization. Names of 4GLs are-
SQL, SAS (Statistical Analysis System), MATLAB (Matrix Laboratory) etc.
(c). Natural Languages (Fifth Generation Language or 5GL): A fifth generation
programming language is a grouping of programming languages build on the
principle that a problem can be solved, and an application built to solve it, by
providing constraints to the program, rather than specifying algorithmically how the
problem is to be solved. Names of 5GLs are- PROLOG (Programming in Logic),
Mercury.
Programs of these languages These are less understandable Programs are less
are easily understandable. than high level languages and understandable.
more understandable than
machine language.
Programs are portable and Programs are machine Programs are machine
machine independent. dependent. dependent.
1
[Author Name]
9
CCSE0151
(i) Compiler
(ii) Interpreter
(iii) Assembler
(i) Compiler: A compiler is a software that translates high level language program into
machine language program. It takes the whole program as input and generate object code
(machine code) file. Name of C compiler are- Turbo C, Borland C.
(ii) Interpreter: An interpreter is a software that translates each high level program statements
into corresponding machine code. It translates one statement at a time and execute it.
(iii) Assembler: An assembler is a software that translates assembly language instructions to
machine language code. The assembler takes each of the assembly language statements
from the source code and generate corresponding bit stream using 0 and 1.
Linker: A linker is a software that takes one or more object file generated by the compiler and
combines them into a single executable file.
Loader: A loader is a software which is used to load the executable file into the primary memory for
execution.
2
[Author Name]
0
CCSE0151
Editor (Text Editor): An editor is a software which is used to create and edit a text file. There are
two types of editors- Line Editor and Screen Oriented Editor.
2
[Author Name]
1
CCSE0151
Algorithm: An algorithm is a sequence of computational steps that transform the input into the
output.
Properties of good Algorithm (Characteristics of algorithm): An algorithm must have the
following properties.
(i)Finiteness: Algorithm must complete after a finite number of instructions have been executed.
(ii) Absence of ambiguity: Each step must be clearly defined.
(iii) Definition of Sequence: Each step must have a unique defined preceding and succeeding
step.
(iv) Input/Output: Number and types of required inputs and outputs must be specified.
(v) Feasibility: It must be possible to perform each instruction.
(vi) Effectiveness: Each step must be effective i.e. it should be easily convertible into program.
Types of Algorithms:
(i). Simple recursive algorithms
(ii). Backtracking algorithms
(iii).Divide and conquer algorithms
(iv).Greedy algorithms
(v). Branch and bound algorithms
Flow Chart: Flow chart is a graphical representation of a process. Each step in the process is
represented by different symbols and contains the short description of the process step.
Advantages:
i. Systematic Debugging and Testing: Flowchart helps to locate bugs and check whether it
produces correct result or not.
ii. Better Communication: It helps the programmer to understand the logic of program and
sequence of instructions.
iii. Efficient Coding: It makes it easy to write the program code.
Disadvantages:
i. Difficulty in Modification: It is not easy to change and modify the symbol of a flow chart.
ii. Time Consuming: It takes more time to draw proper symbol for lengthier programs.
(1) Terminator: Terminator symbol is used to represent the beginning and end of a process.
2
[Author Name]
2
CCSE0151
(3) Data: A data symbol is used to represent input and output in a flow chart.
(5) Connector Lines: Connector lines are used to connect the symbols in a flow chart. The
direction of arrow indicates the next step.
2
[Author Name]
3
CCSE0151
1. Write an algorithm and draw a flow chart to find the area of a circle.
Algorithm:
Step1: Start
Step3: area=3.14*r*r
Step5: End
2. Write an algorithm and draw a flow chart to check that a number is even or odd.
2
[Author Name]
4
CCSE0151
Algorithm:
Step1: Start
Step4: End
3. Write an algorithm and draw a flow chart to find largest number among three numbers.
Algorithm:
Step1: Start
Step2: Read three numbers
Step3: if a>b then
(a). if a>c then a is largest
(b). else c is largest
Step4: else
(a). if b>c then b is largest
(b). else c is largest
Step5: End
2
[Author Name]
5
CCSE0151
2
[Author Name]
6
CCSE0151
Algorithm:
Step1: Start
Step2: Read an integer number N
Step3: Set M=1, F=1
Step4: F=F*M
Step5: M=M+1
Step6: if (M<=N) then goto step4
Step7: else display F
Step8: End
2
[Author Name]
7
CCSE0151
8. Draw a flow chart to display n Fibonacci terms and also print their sum.
2
[Author Name]
8
CCSE0151
2
[Author Name]
9
CCSE0151
Top down Programming Approach: To find the solution to a problem, this approach
divides a problem into sub problems and further sub problems up to desired level. It then finds the
solution of all sub problems and then combine these solutions.
C Character set: C character set consist of the symbols that are used to represent the
instructions in C programming. There are following four types C character set-
(i) Letters: A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z.
3
[Author Name]
0
CCSE0151
a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z.
(ii) Digits: 0,1,2,3,4,5,6,7,8,9.
(iii) Special Characters: ,(Comma), .(Period), ;(Semicolon), ?(Question mark), ‘(Apostrophe),
“(Quotation mark), !(Exclamation Mark), |(Vertical bar), /(Slash), \(Back Slash), ~(Tilde),
_(Underscore), $(Dollar sign), %(Percent Sign), &(Ampersand), ^(Caret), *(Asterisk), –(minus
sign), +(Plush sign), <(Opening angle bracket), >(Closing angle bracket), ((left parenthesis), )
(Right parenthesis), [(Left bracket), ](Right bracket), {(Left brace), }(Right Brace), #(Hash).
(iv) White Space: Blank space, Horizontal tab, Newline, Carriage return, Form Feed.
C Tokens: Smallest individual units in a C program are known as C tokens. There are following six
types of tokens in C programming- Keywords, Identifiers, Constants, Strings, Special Symbols and
Operators.
C Tokens
Keywords: Keywords are the reserve words in C programming. All keywords have fixed meanings
and these meanings cannot be changed. There are 32 keywords in C programming. These 32
keywords are- auto, break, case, char, const, continue, default, do, double, else, enum, extern,
float, for, goto, if, int, long, register, return, short, signed, sizeof, static, struct, switch, typedef,
union, unsigned, void, volatile, while.
3
[Author Name]
1
CCSE0151
1. Keywords are the reserve words which 1. Identifiers are the names of variables,
have fixed meaning. And their meaning functions and arrays. These are programmer
cannot be changed by the programmer. defined names.
2. They are always written in lowercase. 2. They can be written in lowercase or
uppercase.
Example:
Example:
int, char, if, switch, case, break, continue, else,
default. sum, a, x, average, A, AREA etc.
Constants: Constants are the fixed values that do not change during the execution of program. They
are also called as literals. There are following types of constants in C.
Integer constants
Real or Floating point constants
Octal & Hexadecimal constants
Character constants
String constants
Backslash character constants
String: A string is a collection of characters. String constants are always enclosed in double quote.
For example: “Computer”, “A” etc. are strings.
Data Types: The data types determine the types of values and range of values that can be stored
in a variable. Data types also define a set of operations that can be applied on these values. There
are following three types of data types in C programming.
(i) Primary Data Types (Fundamental or Primitive or Built-in Data Types)
(ii) Derived Data Types
(iii) User Defined Data Types
Data Types
Primary Data Types Derived Data Types User Defined Data Type
Character (char) Array Enumeration
Integer (int) Pointer Typedef
3
Float (float) [Author Name]
Structure
2
Double (double) Union
Void (void)
CCSE0151
3
[Author Name]
3
CCSE0151
Variable: A variable is a data name that may be used to store data value. A variable can take
different values during the execution of program.
There are two types of variables: (scope of variables)
(i) Local Variables
(ii) Global Variables
(i) Local Variables: A variable that is declared inside a function is known as local variable to that
function. A local variable can only be used in the function where it is declared.
(ii) Global Variable: A variable that is declared outside all functions is known as global variable.
A global variable can be used in all functions.
Variable Declaration: A variable can be declared as-
Syntax: data-type variablename;
Example: int a, b, sum;
3
[Author Name]
4