Unit 1 Introduction To Programming

Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

Unit 1: Introduction to Programming, Introduction to components of a computer system

(disks, memory, processor, where a program is stored and executed, operating system,
compilers etc.)

What is programming?
The process or activity of writing computer programs.
Programming involves creating code that Programmers can enter into a computer,
application, or software program. This code instructs the device how to perform.

Introduction to components of a computer system


Computer systems consist of three components as shown in below image:

1. Central Processing Unit [Control Unit, Memory Unit and ALU Unit]
2. Input Unit
3. Output Unit.

Input Unit:

The input unit consists of input devices that are attached to the computer. These devices take
input and convert it into binary language that the computer understands. Some of the common
input devices are keyboard, mouse, joystick, scanner etc.

Output Unit :

The output unit consists of output devices that are attached to the computer. It converts the
binary data coming from the CPU to human understandable form. The common output devices
are monitor, printer, plotter, etc.
Central Processing Unit

The Central Processing Unit (CPU) is called "the brain of computer" as it controls operation of all
parts of computer. It consists of following components :

1. Arithmetic Logic Unit (ALU)


2. Control Unit.
3. Memory Unit.

Arithmetic Logic Unit (ALU)

Data entered into computer is sent to RAM, from where it is then sent to ALU, where rest of data
processing takes place. All types of processing, such as comparisons, decision-making and
processing of non-numeric information takes place here and once again data is moved to RAM.

Arithmetic calculations include addition, subtraction, multiplication and division. Logical decisions
involve the comparison of two data items to see which one is larger or smaller or equal.

Control Unit

As name indicates, this part of CPU extracts instructions, performs execution, maintains and
directs operations of entire system.

Functions of Control Unit

1. Fetch
2. Decode
3. Execute
4. Write back
Control unit performs following functions −

1. It controls all activities of computer


2. Supervises flow of data within CPU
3. Directs flow of data within CPU
4. Transfers data to Arithmetic and Logic Unit
5. Transfers results to memory
6. Fetches results from memory to output devices

Memory Unit

This is unit in which data and instructions given to computer as well as results given by computer
are stored. Unit of memory is "Byte". Memory attached to the CPU is used for the storage of data
and instructions, and is called internal memory

1 Byte = 8 Bits

What is Disk?

Alternatively known as a diskette, a disk is a hard or floppy round, flat, and magnetic platter
capable of having information read from and written to it.

Types of disks

There are two basic types of disks in the computer hardware realm:

1. Magnetic disks
2. Optical disks.

Magnetic Disks:
Description:

Composition: Magnetic disks, also known as hard disk drives (HDDs), consist of one or more
magnetic platters coated with a ferrous material.
Read/Write Mechanism: Data is stored on the surface of these platters in binary form (0s and
1s) using a magnetic read/write head.
Speed: Typically have faster data access speeds compared to optical disks.
Capacity: Generally offer higher storage capacities compared to optical disks.
Durability: More susceptible to physical damage due to their mechanical parts and sensitive
platter surfaces.

Optical Disks:
Description:

Composition: Optical disks include various types like CD (Compact Disc), DVD (Digital
Versatile Disc), and Blu-ray.
Read/Write Mechanism: Data is read and written using a laser beam. Pits and lands on the
disk surface represent binary data.
Speed: Generally slower in terms of data access compared to magnetic disks.
Capacity: Typically have lower storage capacities compared to magnetic disks.
Durability: More resistant to physical damage compared to magnetic disks.

Magnetic disks are more commonly used for primary storage and active data access due to their
higher capacities and faster speeds.
Optical disks are often used for distribution and archival purposes, especially when a write-once,
read-many (WORM) model is desired.
In modern computing, solid-state drives (SSDs) have become increasingly popular, offering
benefits like faster data access speeds, durability, and efficiency, while overcoming some
limitations of traditional magnetic disks.

Hard Drives
Floppy Drives

CD-ROM
CD-R
CD-RW
DVD-ROM
DVD-R
DVD+R
DVD-RW
Blue Ray
Removable Drives

HARD DRIVES

These are also called 'fixed disks' in ancient computerese because the storage media is mounted
within the computer and not intended to be removed.

Hard drives consist of one or more metal platters stacked together on a single spindle. Multiple
read/write heads (one for the top and bottom of each platter) float next to the surface of the
drive. Hard Disk drive capacities are determined by the number of cylinders and blocks per
cylinder a drive will support.
FLOPPY DRIVES

Named for the media disks that could be pulled out and that would 'flop' when carried. These
disks are designed to allow users to store data to a disk, remove it and carry the data elsewhere.
These typically come in one of two formats in the United States: 3.5" @1.44Mbytes and 5.25" at
1.22 Mbytes. There are a few proprietary types as well, such as Zip drives, DAT tapes etc.

CD-ROM
Compact Disk Read Only Memory or CD-ROMs are shiny circular pieces of plastic with a hole in
the middle. These look like audio compact disks and computer software and data are stored on
them. They are read using a powerful (red) light-emitting diode (LED) that is sometimes called a
'laser' and thus the name 'laser disk'. Compact Disk media is made of pressed layers of plastic and
can store about 640 MB of data.

DVD-ROM

Digital Video Disks were first used to store movies for playback on compact players.

Blu-Ray
The latest development in data storage and movie disks is Blu-Ray, so called because it uses a
blue LED (sometimes called a laser, which is actually something entirely different) to read/write
from the disk.

REMOVEABLE DRIVES

These are drives where the drive itself can be removed or ported elsewhere. The media is usually
not pulled out. Removable hard drives are a good example of these.

Memory
Memory in computers refers to the electronic components used to store and retrieve data for
processing. There are two primary types of memory in a computer system:

1. Primary Memory (RAM - Random Access Memory):

Description: RAM is volatile memory used by the computer to store and quickly retrieve data
that the CPU is actively using or processing.
Functionality: It provides fast access to data and instructions, enabling the CPU to perform
operations quickly. However, its contents are lost when the computer is powered off.
Types: Different types of RAM include DRAM (Dynamic RAM) and SRAM (Static RAM).

2. Secondary Memory (Storage Devices):

Description: Secondary memory refers to non-volatile storage devices that retain data even
when the computer is turned off.
Functionality: It is used for long-term storage of data, applications, and the operating system.
Unlike RAM, it retains data even during power cycles.
Types: Common types of secondary memory include Hard Disk Drives (HDDs), Solid State
Drives (SSDs), optical disks (CDs, DVDs, Blu-rays), and USB drives.
Key Points:

RAM (Primary Memory):

Characteristics:

Volatile: Loses data when power is turned off.


Faster access speed compared to secondary memory.

Uses:

Actively used by the CPU during program execution.


Provides quick access to data and instructions.
Acts as a workspace for running applications.
Storage Devices (Secondary Memory):

Characteristics:

Non-volatile: Retains data even when the power is turned off.


Slower access speed compared to RAM.

Uses:

Long-term storage of data, applications, and the operating system.


Holds files and software installations.
Used for backup and archival purposes.
Cache Memory (Between RAM and CPU):

Characteristics:

Faster and smaller than RAM.


Located between RAM and the CPU.

Uses:

Temporarily stores frequently accessed data to speed up CPU access times.


Acts as a buffer between RAM and the CPU.

Virtual Memory:
Description:

Part of the secondary storage used as an extension of RAM.


Allows the computer to run applications larger than the physical RAM capacity.

Functionality:

Data is swapped between RAM and the hard drive as needed.


Slower than physical RAM but provides more capacity.
Operating system
An Operating System (OS) is a software that acts as an interface between computer
hardware components and the user.

Every computer system must have at least one operating system to run other programs.
Applications like Browsers, MS Office, Notepad Games, etc., need some environment to run
and perform its tasks.
It provides a set of services and functionalities that allow users to interact with the hardware
and run applications.

Functions of Operating System


1. Security
2. File Management
3. Device Management
4. Process Management
5. Memory Management
6. User Interface or Command Interpreter
7. Network Management
Process management: Process management helps OS to create and delete processes. It also
provides mechanisms for synchronization and communication among processes.
Memory management: Memory management module performs the task of allocation and
de-allocation of memory space to programs in need of this resources.
File management: It manages all the file-related activities such as organization storage,
retrieval, naming, sharing, and protection of files.
Device Management: Device management keeps tracks of all devices. This module also
responsible for this task is known as the I/O controller. It also performs the task of allocation
and de-allocation of the devices.
I/O System Management: One of the main objects of any OS is to hide the peculiarities of
that hardware devices from the user.
Secondary-Storage Management: Systems have several levels of storage which includes
primary storage, secondary storage, and cache storage. Instructions and data must be stored
in primary storage or cache so that a running program can reference it.
Security: Security module protects the data and information of a computer system against
malware threat and authorized access.
Command interpretation: This module is interpreting commands given by the and acting
system resources to process that commands.
Networking: A distributed system is a group of processors which do not share memory,
hardware devices, or a clock. The processors communicate with one another through the
network.
Job accounting: Keeping track of time & resource used by various job and users.
Communication management: Coordination and assignment of compilers, interpreters, and
another software resource of the various users of the computer systems.

Types of an Operating System


1. Single user OS

Single User Single-Tasking [DOS]


Single User Multi-Tasking [Windows 95/97]
2. Multi-user OS [UNIX, LINUX]

Single-User Single-Tasking: Operating system allows a single user to execute one program at a
particular time. This operating system is designed especially for wireless phones and two-way
messaging. Some functions such as printing a document, and downloading images and videos are
performed in one given frame.

Example: MS-DOS, Palm OS (Used in Palm-held computers).

MS-DOS

MS-DOS which is short for Microsoft Disk Operating System is a non-graphical command line
operating system developed for IBM compatible computers with x86 microprocessor. The
operating system used a command line interface for the user to input commands to navigate,
open and manipulate files on their computer.

Features:

It is a single user operating system meaning only one user can operate at a time.
It is a light weight operating system allowing users to have direct access to the BIOS and its
underlying hardware.
Loads data and programs from external sources and bring them into the internal memory so
they can be used on the computer.
Enables the computer to perform input and output operations such as taking commands
from keyboard, printing information on the screen.
It is very helpful in making file management like creating, editing, deleting files, etc.
It also controls and manages other external devices such as the printer, keyboard or external
hard drive using various drive utilities.

Drawbacks:

It does not allow multiple users to operate on the system.


It does not support graphical interface hence mouse cannot be used to operate it.
It does not support multiprogramming meaning it can only have one process in the ram.
It lacked memory protection which meant no security, and less stability.
It has difficulty in memory access when addressing more than 640 MB of RAM.

Single-User Multi-Tasking: Operating system allows a single user to execute multiple programs
at the same time, the single user can perform multiple tasks at a time. This type of operating
system is found on personal desktops and laptops. The most popular single-user multi-tasking is
Microsoft windows. This single-user multi-tasking can be pre-emptive or cooperative.

Example: Windows

Windows Operating System

Windows is an operating system designed by Microsoft to be used on a standard x86 Intel and
AMD processors. It provides an interface, known as a graphical user interface(GUI) which
eliminates the need to memorize commands for the command line by using a mouse to navigate
through menus, dialog boxes, buttons, tabs, and icons. The operating system was named
windows since the programs are displayed in the shape of a square. This Windows operating
system has been designed for both a novice user just using at home as well as for professionals
who are into development.

Features:

It is designed to run on any standard x86 Intel and AMD hence most of the hardware
vendors make drivers for windows like Dell, HP, etc.
It supports enhanced performance by utilizing multi-core processors.
It comes preloaded with many productivity tools which helps to complete all types of
everyday tasks on your computer.
Windows has a very large user base so there is a much larger selection of available software
programs, utilities.
Windows is backward compatible meaning old programs can run on newer versions.
Hardware is automatically detected eliminating need of manually installing any device
drivers.

Drawbacks:

Windows can be expensive since the OS is paid license and majority of its applications are
paid products.
Windows has high computer resource requirement like it should have high RAM capacity, a
lot of hard drive space and good graphics card.
Windows slows and hangs up if the user loads up many programs at the same time.
Windows includes network sharing that can be useful if user has a network with many PCs.
Windows is vulnerable to virus attacks since it has a huge user base and users have to
update OS to keep up-to-date with security patches.
2. Multi-User Operating System
In a multiuser operating system, multiple numbers of users can access different resources of a
computer at the same time. The access is provided using a network that consists of various
personal computers attached to a mainframe computer system. A multi-user operating system
allows the permission of multiple users for accessing a single machine at a time. The various
personal computers can send and receive information to the mainframe computer system. Thus,
the mainframe computer acts as the server and other personal computers act as clients for that
server.

Multi-user operating systems is of the following types:

1. Distributed System: The distributed operating system also known as distributed computing is
a collection of multiple computers located on different computers. Communicate and coordinate
their actions by passing messages to one another from any system.

Examples: Electronic banking, Mobile apps

2. Time sliced system: It is the system where each user talk is allocated to a short span of cpu
time. A small time duration is allotted to every task. CPU time is divided into small time slices, and
one time is assigned to each other.

Example: Mainframe, a partial exam of the time-sliced system.

3. Multiprocessor system: It involves multiple processors at a time. Enhance the overall


performance. If one processor fails other continues working.

Example: Spreadsheets, Music player

4. LINUX Operating System


The Linux OS is an open source operating system project that is a freely distributed, cross-
platform operating system developed based on UNIX. This operating system is developed by
Linus Torvalds. The name Linux comes from the Linux kernel. It is basically the system software
on a computer that allows apps and users to perform some specific task on the computer. The
development of Linux operating system pioneered the open source development and became the
symbol of software collaboration.

Features:

Linux is free can be downloaded from the Internet or redistribute it under GNU licenses and
has the best community support.
Linux OS is easily portable which means it can be installed on various types of devices like
mobile, tablet computers.
It is a multi-user, multitasking operating system.
BASH is the Linux interpreter program which can be used to execute commands.
Linux provides multiple levels of file structures i.e. hierarchical structure in which all the files
required by the system and those that are created by the user are arranged.
Linux provides user security using authentication features and also threat detection and
solution is very fast because Linux is mainly community driven.

Drawbacks:

There’s no standard edition of Linux hence confusing for users and also becoming familiar
with the Linux may be a problem for new users.
More difficult to find applications to support user needs since Linux does not dominate the
market.
Since some applications are developed specifically for Windows and Mac, those might not be
compatible with linux and sometimes users might not have much of a choice to choose
between different applications like in Windows or Mac since most apps are developed for
operating systems that have a huge user base.
Some hardware may not be incompatible with Linux since it has patchier support for drivers
which may result in malfunction.
There are plenty of forums to resolve Linux issues, but it may not always match the user’s
own level of technical understanding.

Compilers in c
There are several C compilers available, catering to different platforms and development
environments. Here's a list of some popular C compilers:

1. GCC (GNU Compiler Collection):

A highly popular open-source compiler that supports multiple programming languages,


including C, C++, and Fortran.
Available on various platforms, including Unix-like systems (Linux, macOS) and Windows.
Command to compile a C program: gcc source_file.c -o output_file

2. Clang:

Part of the LLVM (Low-Level Virtual Machine) project.


Known for fast compilation and expressive diagnostics.
Supports multiple platforms, including Unix-like systems and Windows.
Command to compile a C program: clang source_file.c -o output_file

3. Microsoft Visual C++ (MSVC):

Provided by Microsoft for Windows development.


Often used with the Visual Studio integrated development environment (IDE).
Command to compile a C program using MSVC: cl /EHsc source_file.c

4. Intel C++ Compiler:

Optimized compiler for Intel architecture-based processors.


Often used for performance-critical applications.
Supports both Windows and Linux.
Command to compile a C program: icc source_file.c -o output_file

5. TinyCC (TCC):

A lightweight, fast compiler designed for simplicity and speed.


Suitable for small to medium-sized projects.
Available on various platforms.
Command to compile a C program: tcc source_file.c -o output_file

6. Digital Mars C/C++ Compiler:

A compiler suite for Windows development.


Supports both C and C++.
Command to compile a C program: dmc source_file.c

7. Pelles C:
A complete development environment for Windows.
Includes an integrated development environment (IDE) along with the compiler.
Command to compile a C program: Use the Pelles C IDE.

8. Cygwin:

Provides a Unix-like environment on Windows.


Includes GCC and other tools for compiling C programs in a Unix-like environment.
Command to compile a C program: gcc source_file.c -o output_file (within the Cygwin
terminal)

9. MinGW (Minimalist GNU for Windows):

A native Windows port of the GNU Compiler Collection.


Allows development on Windows using GCC.
Command to compile a C program: gcc source_file.c -o output_file

You might also like