0% found this document useful (0 votes)
2 views

C Programming Laboratory Information

The document provides an overview of C programming, computer hardware, and operating systems, detailing the functions of various computer components such as the CPU, memory, and input/output devices. It explains the types of operating systems and their functions, along with storage media options like hard disks and optical media. Additionally, it discusses problem-solving techniques in programming, including algorithms, flowcharts, and pseudo code.

Uploaded by

deepakadur123
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

C Programming Laboratory Information

The document provides an overview of C programming, computer hardware, and operating systems, detailing the functions of various computer components such as the CPU, memory, and input/output devices. It explains the types of operating systems and their functions, along with storage media options like hard disks and optical media. Additionally, it discusses problem-solving techniques in programming, including algorithms, flowcharts, and pseudo code.

Uploaded by

deepakadur123
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

C Programming Laboratory

Introduction:
C is a procedural programming language. Dennis Ritchie initially developed it
between 1969 and 1973. It was mainly developed as a system programming language to write
operating system. The main features of C language include low-level access to memory, a
simple set of keywords, and clean style, these features make C language suitable for system
programming like operating system or compiler development. Many later languages have
borrowed syntax/features directly or indirectly from C language. C is a simple and flexible
general-purpose programming language. It is a machine-independent, structured
programming language which is used extensively in various applications.
C was the basics language to write everything from operating systems (Windows and
many others) to complex programs like the Oracle database, Git, Python interpreter and more.

Theory of Computer
Familiarization with computer hardware and programming environment, concept of
naming the program files, storing, compilation, execution and debugging. Taking any
simple C- code.
THEORY:
Description about Functional block diagram of Computer:
A computer is an electronic device, which mainly performs the four functions as
reading, processing, displaying and storing on data. These functions of a computer system
can be carried out by using the three main units namely input unit, system unit and output
unit. The block diagram of a computer system is as follows:

Fig 1: Block Diagram of a Computer

Notations:
Data and Results flow
Control instructions to other units from control unit
Instructions from memory unit to control unit
System or Central Processing Unit (CPU): is commonly known as “processor” that
executes the instructions of a computer program. It has Control Unit (CU) and Arithmetic &
Logical Unit (ALU). These two units perform the basic arithmetic, logical, and input/output
operations.

a) Input unit: is used to enter data and information into a computer. The devices like
keyboard, mouse and scanner are commonly used input devices.
A keyboard is used to enter alphanumeric characters and symbols.
The mouse is used to pick or select a command from the monitor screen.
A scanner is used to scan an image or read a barcode and so on.
b) Arithmetic and Logic Unit (ALU): is a digital circuit that perform arithmetic (Add, Sub,
Multiplication, Division) and logical (AND, OR, NOT) operations. It helps in fast
computation of scientific calculations on floating-point number.

c) Control unit (CU): is the circuitry that controls the flow of information through the
processor and coordinates the activities of the other units within the processor.

Functions of Control unit: Accessing data & instructions from memory unit. Interpreting
instructions Controlling input and output units.Overall supervision of a Computer system
d) Memory Unit (MU): is the unit where all the input data and results are stored either
temporarily or permanently. The CPU memory is also called as memory register. The
memory of a computer has two types:
a. Main Memory / Primary Memory units
i. Random Access Memory (RAM)
ii. Read Only Memory (ROM)
b. Secondary Memory / Auxiliary Memory
e) Output Unit: It is used to display or print results from a computer. Monitor, printer
and plotters are commonly used output devices.

f) Bus: A bus is a collection of wires that carries data/Instructions. It connects physical


components such as cables, printed circuits, CPU, Memory, Peripherals etc., for sharing of
Information and communication with one another.

Main Board or Mother Board: Mother Board is a set of Integrated Chips (ICs) which are designed
to work together. It controls the flow of data/instructions within our computer. It is the main board on
which other hardware components are connected to enable the computer system to work as an
integrated unit. It consists of sockets, slots, power connectors and bus.

Chip sets: Chip set is the set of integrated chips that are designed to work together. These set of
chips controls the flow of information on computer. The chips may be controllers for memory, cache,
hard drive, key board and peripherals.
Operating System and its types: An Operating System
(OS) is system software that controls and supervCSEs
the hardware components of a computer system and it
provides the services to computer users. Also called as
Resource Manager that manages the resources such as
CPU, Memory, I/O devices, Job/Task/Process etc., a
computer cannot run without it. The major functions of OS
includes: CPU Management, Memory Management, File

Management, Device Management, Process/Task/Job Management and Security Management.


The primary goal of an OS is to make the computer system convenient and efficient to use. An OS
ensures that thesystem resources (such as CPU, memory, I/O devices, etc) are utilized efficiently. For
example, there may be manyprograms residing in the main memory.
Some of the examples of Operating Systems:
Windows –XP is an O.S. is used for Personal Computers (PCs) Unix and XENIX are the OSs
used for multi-user computers. Windows 7, Windows 8, Macintosh OS, Fedora, and Android,
etc.
Types of Operating Systems: The operating systems are classified into 7 types based on their
capability and usage.

Fig 3: Types of OS

Batch Processing Tasking OS: The data is collected into a group called batch and provides
only one batch (one after another) of jobs as input to the computer system at a time. The jobs in a
batch are processed on first come first serve basis. In this type, the process takes place at specified
time intervals i.e. weekly or monthly without user interaction.

Single user and single tasking OS: The OS that allows only one program to execute at a time is
calledsingle user single tasking operating system. Using this operating system user can do
only one task at a time. E.g. DOS (Disk Operating System).
Single user and multi tasking OS: The OS that allows a single use to perform more than
one task at a time is called single user multi tasking operating system. While working with
the Ms-Word user can perform other work like print a document, listen music.E.g.
Windows-XP, Windows Vista, Windows – 7, etc.
Multi user and multitasking OS: The O.S. that allows two or more users to use a main
computer system to do more than one task is called multiuser and multitasking operating
system.E.g. UNIX is a multiuser and multitasking operating system.
Multiprocessing OS: The OS that allows multiple programs to be executed by multiple
CPUs
(Processors) is called multiprocessing operating system. Super and main frame computers
have more than one CPU and multiprocessing operating system.
Real Time Operating System (RTOS): The OS that is used for real time
applications and to carry out certain calculations within the specified time constraint. This OS
is used in applications such as mobile phones, supporting systems in hospitals, nuclear power
plants, oil refining, chemical processing, environmental applications and air-traffic control systems,
disaster management etc.,

Virtual machine OS: Allows several users of a computer system to operate as if each
has the only terminal attached to the computer.

Random Access Memory (RAM): RAM is basically main memory of the


computer. RAM is a semiconductor memory made up of small memory
chips that form a memory module. These modules are installed in the RAM
slots on the motherboard of computer. Every time you open a program, it
gets loaded from the hard drive into the RAM.

Synchronous Dynamic Random Access Memory (SDRAM): It is an improvement to


standard DRAM because it retrieves data alternately between two sets of memory. This
eliminates the delay caused when one bank of memory addresses is shut down while another
is prepared for reading. It is called "Synchronous" DRAM because the memory is
synchronized with the clock speed that the computer's CPU bus speed is optimized for.
FLASH memory: Flash memory is a type of Electrically Erasable Programmable Read-
Only Memory (EEPROM). The name comes from how the memory is designed -- a section
of memory cells can be erased in a single action or in a "flash.” Flash memory cards used for
digital cameras, cellular phones, networking hardware, and PC cards.

Hard disks: Hard disk is prime unit of storage of the computer. Huge amount of data can be
stored and accessed in few millCSEconds. The hard disk consists of more number of disks
arranged in the cylindrical order, one above another on a spindle.
The read/write heads are attached to single access
mechanism so that they cannot move independently. All
read/write heads are moved together to position that
heads on the required track. The hard disks available
today ranges from 200 GB to 2TB and so on. The present
day hard disk ranges from 3600 rpm to more than 10000
rpm and so on.
Advantages: High storage capacity, high data accessing
rate and permanent storage medium.
Disadvantages: It is not portable.
Optical media: An optical storage media is kind of storage, which is coated with thin
metal on which bits are stored. The data can be stored in to optical storage media or read
form the optical storage media.

Examples: CD-ROM, DVD etc.

Compact Disc Read-Only-Memory (CD-ROM): It is a type of optical disc that uses laser
technology to read and write data on the disc. The information stored on CDROM becomes
permanent and cannot be altered. This means that the stored information can only be read
for processing.

A CD-ROM uses the round shaped optical disk to store data,


applications, games and audio files. It can store up to 700 MB of data. It has
become integral part of every organization due to its features like reliability,
reasonable, storage capacity and easy to use of carry.

Compact Disk Recordable (CD-R): The CD-R allows you to create your own CD.CD-R
drives have the ability to create CDs but they can write data on the disk only once.CD-R
technology also called as Write Once-Read much (WORM) technology. Laser technology is
used to write the data on the compact disk.CD-R drives come in IDE, SCSI and USB
models.
Compact Disc Rewritable (CD-RW): CD-RW is an erasable optical disk which is used to
write data multiple times on a disk, CD-RW disks are good for data backup, data archiving
or data distribution on CDs. The disk normally holds 700MB of data. Technology to write
data multiple times on a CD was known as the Phase change Dual (PD) technology.
Disk or Digital Versatile Disc (DVD-ROM): A DVD is a small optical disk having high
density medium and capable of storing a full-length movie on a single disk. The high density
is achieved by using both sides of the disk, special data-compression technology, and
extremely small tracks to store the data.
Advantages: Storage capacity is more compared to CDs.
Flash Drives (Pen drives): USB flash drives are removable, rewritable, and physically much
smaller drives weighing even less than 30 g. A flash drive consists of a small printed circuit
board carrying the circuit elements and a USB connector, insulated electrically and protected
inside a plastic, metal, or rubberized case which can be carried in a pocket or on a key chain.
Advantages
Data stored on flash drives is impervious to scratches and dust
Mechanically very robust
Easily portableHave higher data capacity than any other removable media. Compared to hard
drives, flash drives use little power
Disadvantages
Can sustain only a limited number of write and erase cycles before the drive fails.
Most flash drives do not have a write-protect mechanism

Keyboard: A keyboard is the primary input device used in all computers. Keyboard has a
group of switches resembling the keys on an ordinary typewriter machine. Normally
keyboard has around 101 keys. The keyboard includes key that allows us to type letters,
numbers and various special symbols such as *, /, [, % etc.
Mouse: The mouse is the key input device to be used in a Graphical User Interface (GUI).
The users can use mouse to handle the cursor pointer easily on the screen to perform various
functions like opening a program or file.
Advantages:
Easy to use; Cheap; Can be used to quickly place the cursor anywhere on the screen
Helps to quickly and easily draw figures
Point and click capabilities makes it unnecessary to remember certain commands
Disadvantages:
Needs extra desk space to be placed and moved easily
The ball in the mechanical mouse needs to be cleaned very often for smooth movements
Printers: The printer is an output device, which is used to get hard copy of the text
displayed on the screen. The printer is an external optional device that is connected to the
computer system using cables. The printer driver software is required to make the printer
working.
Plotters: A plotter is similar to printer that produces hard-copy output with high-quality color
graphics.Plotters are generally more expensive than printers, ranging from about $1000 to
$75000.
Problem Solving Techniques:
The process of working through details of a problem to reach a solution. There are three
approaches to problem solving:
1. Algorithm
2. Flowchart
3. Pseudo Code
Algorithm: The algorithm is a step-by-step procedure to be followed in solving a problem.
It provides a scheme to solve a particular problem in finite number of unambiguous steps.
It helps in implementing the solution of a problem using any of the programming
languages.
Definiteness: Instructions must be precCSE and unambiguous i.e. each and every
instruction should be clear and should have only one meaning.
Finiteness: Not even a single instruction must be repeated infinitely. i.e., each
instruction should be performed in finite time.
Termination: After the algorithm gets executed, the user should get the desired result
Key features of an algorithm:
Any algorithm has a finite number of steps and some steps may involve decision
making, repetition. Broadly speaking, an algorithm exhibits three key features that can
be given as:

Sequence: Sequence means that each step of the algorithm is executed in the specified order.
Decision: Decision statements are used when the outcome of the process depends on some
condition.
Repetition: Repetition which involves executing one or more steps for a number of times can
be implemented using constructs like the while, do-while and for loops. These loops
executed one or more steps until some condition is true.
Example: To compute the Area of Rectangle
ALGM: AREA_of_RECTANGLE [This algorithm takes length and breadth, the sides of
the rectangle as input and computes the area of rectangle using the formula area=length *
breadth. Finally it prints the area of rectangle]
STEPS:
Step 1:[Initialize]
Start
Step 2: [Input the sides of Rectangle]
Read length, breadth
Step 3:[Compute the area of rectangle]
Area=length*breadth
Step 4:[Display the Area]
Print Area
Step 5: [Finished]
Stop
Flowcharts: A flowchart is a graphical or symbolic representation of an algorithm. They are
basically used to design and develop complex programs to help the users to visualize the
logic of the program so that they can gain a better understanding of the program and find
flaws, bottlenecks, and other less-obvious features within it. Basically, a flowchart depicts
the “flow” of a program. The following table shows the symbols used in flowchart along
with its descriptions.

You might also like