CProgchap 1notes
CProgchap 1notes
Com, BBA,BDA
Journey to Fundamentals and C Programming concepts
Chapter – 1
Introduction to Computers
Computers are electronic devices that can perform various tasks, including data processing, calculations, and
communication.
They consist of both hardware and software components, which work together to execute tasks.
Computers have become an integral part of modern life, used in various fields like business, education,
entertainment, and science.
Hardware:
Hardware refers to the physical components of a computer system. These components are tangible and include
items such as the central processing unit (CPU), memory (RAM), storage devices (hard drives, SSDs),
input/output devices (keyboard, mouse, monitor), and more.
Hardware is responsible for the execution of software and performing tasks as instructed by the software.
Software:
Software refers to the intangible programs and data that run on a computer system. It is a set of instructions
that tell the hardware how to perform specific tasks.
There are three primary types of software: system software, application software, and utility software.
1. System Software:
System software is essential for managing and controlling computer hardware. It includes the operating
system and various system utilities.
The operating system (OS) is the core system software that manages hardware resources, provides a user
interface, and runs and manages applications.
System utilities are tools used to maintain and optimize the computer system. Examples include disk
defragmenters, antivirus software, and device drivers.
2. Application Software:
Application software is designed to perform specific tasks or applications for end-users. It includes a wide
range of programs, from word processors to graphic design tools, web browsers, and games.
Application software can be classified into different categories, such as productivity software, entertainment
software, and educational software, based on their intended use.
3. Utility Software:
Utility software is a set of programs that serve various maintenance and optimization functions. It helps users
manage and maintain their computer systems.
Examples of utility software include antivirus software, backup tools, disk cleanup utilities, and system
optimization programs.
System Software
System software is a crucial component of a computer system that manages and controls hardware and
provides a platform for running application software. It acts as an intermediary between the user and the
computer hardware, ensuring the efficient and reliable operation of the system. System software plays a vital
role in managing tasks such as memory, file management, input/output operations, and more. There are
several types of system software, each with its specific functions and purposes.
Types of System Software:
Operating System (OS): The operating system is the core software that controls and manages the hardware
resources of a computer, enabling the execution of application programs.
Examples: Windows, macOS, Linux, Unix, Android.
1. Compiler: A compiler is a software tool that translates high-level programming code into machine
code or an intermediate language, making it executable by the computer's hardware.
2. Assembler: An assembler is a software tool that converts assembly language code into machine code,
allowing for low-level programming and hardware-specific operations.
3. Linker: A linker is a system software component that combines multiple object files, libraries, and
dependencies into a single executable program.
4. Loader: A loader is responsible for loading executable files into memory, preparing them for
execution, and managing dynamic linking and relocation.
5. Device Drivers: Device drivers are software components that facilitate communication between the
operating system and hardware devices such as printers, graphics cards, and network adapters.
6. Utility Programs: Utility programs are system software tools designed to perform various maintenance
and system-related tasks, enhancing the efficiency and functionality of a computer system.
Application Software:
Definition of Application Software: Application software, often referred to as apps, is a set of computer
programs designed to perform specific tasks or functions for end-users. Unlike system software, which
manages and supports the hardware and basic computer operations, application software is user-oriented and
serves various purposes, from productivity to entertainment.
Types of Application Software:
1. Word Processing Software:
Examples: Microsoft Word, Google Docs, LibreOffice Writer.
Purpose: Word processors are used for creating, editing, formatting, and printing documents. They are widely
employed for writing reports, letters, essays, and other text-based content.
2. Spreadsheet Software:
Examples: Microsoft Excel, Google Sheets, LibreOffice Calc.
Purpose: Spreadsheet applications enable users to create, manage, and analyze data in tabular format. They are
valuable for tasks like financial calculations, budgeting, and data analysis.
3. Presentation Software:
Examples: Microsoft PowerPoint, Google Slides, LibreOffice Impress.
Purpose: Presentation software allows users to create and deliver multimedia presentations. It's essential for
business presentations, educational lectures, and public speaking.
4. Database Software:
Examples: Microsoft Access, MySQL, Oracle Database.
Purpose: Database software helps users store, retrieve, and manage data efficiently. It is commonly used in
business for tasks such as customer relationship management (CRM), inventory management, and data
analysis.
5. Graphics and Multimedia Software:
Examples: Adobe Photoshop, Adobe Premiere Pro, CorelDRAW.
Purpose: Graphics and multimedia software are used for creating and editing images, videos, and other
multimedia content. They are valuable in the fields of graphic design, video editing, and digital art.
6. Web Browsers:
Examples: Google Chrome, Mozilla Firefox, Microsoft Edge.
Purpose: Web browsers allow users to access and navigate the World Wide Web. They are essential for
browsing websites, conducting online research, and accessing web-based applications.
7. Communication Software:
Examples: Microsoft Outlook, Skype, Slack.
Purpose: Communication software facilitates various forms of communication, including email, instant
messaging, and video conferencing. It is crucial for staying connected in both personal and professional
contexts.
8. Entertainment Software:
Examples: Video games, media players, streaming apps.
Purpose: Entertainment software provides users with leisure and enjoyment. Video games offer interactive
experiences, while media players and streaming apps allow users to consume music, movies, and TV shows.
Computer Languages
Computer languages, also known as programming languages, are specialized methods of communication that
humans use to instruct computers. These languages play a crucial role in the development of software,
allowing programmers to write code and create applications, games, websites, and much more. Computer
languages can be categorized into several types based on their characteristics and usage.
Programming Languages
Programming languages can be broadly categorized into the following types:
1, Low Level Language 2. High Level Language
1. Low Level Language are categorised into following types :
1. Machine Language:
Machine language is the lowest-level programming language.
It consists of binary code (0s and 1s) that directly corresponds to the computer's hardware.
Programs written in machine language are highly efficient but challenging to read and write, as they require a
deep understanding of the computer's architecture.
2. Assembly Language:
Assembly language is a low-level programming language that uses mnemonics and symbols to represent
machine code instructions.
It is more human-readable than machine language and is often used for system-level programming and
hardware interactions.
2. High-Level Languages:
High-level languages are designed to be more human-friendly and abstracted from the hardware.
They offer a higher level of abstraction and are easier to learn and use.
Examples of high-level languages include Python, Java, C++, and Ruby.
2. Interpreter
Interpreter is a translator which is used to convert programs in high-level language to low-level language.
Interpreter translates line by line and reports the error once it encountered during the translation process.
It directly executes the operations specified in the source program when the input is given by the user.
It gives better error diagnostics than a compiler.
Differences between compiler and interpreter
3. Assembler
Assembler is a translator which is used to translate the assembly language code into machine language code.
Assembly language is a low-level human-readable language that is specific to a particular computer
architecture.
Assemblers are used to develop system software, device drivers, and embedded systems.
Computer Virus :
A computer virus is a kind of malicious computer program, which when executed, replicates itself and inserts
its own code. When the replication is done, this code infects the other files and program present on your
system.
These computer viruses are present in various types and each of them can infect a device in a different
manner.
Since the computer virus only hits the programming of the device, it is not visible. But there are certain
indications which can help you analyse that a device is virus-hit. Given below are such signs which may help
you identify computer viruses:
Speed of the System – In case a virus is completely executed into your device, the time taken to open
applications may become longer and the entire system processing may start working slowly
Pop-up Windows – One may start getting too many pop up windows on their screen which may be
virus affected and harm the device even more
Self Execution of Programs – Files or applications may start opening in the background of the system
by themselves and you may not even know about them
Log out from Accounts – In case of a virus attack, the probability of accounts getting hacked increase
and password protected sites may also get hacked and you might get logged out from all of them
Crashing of the Device – In most cases, if the virus spreads in maximum files and programs, there are
chances that the entire device may crash and stop working
Boot Sector Virus – It is a type of virus that infects the boot sector of floppy disks or the Master Boot
Record (MBR) of hard disks. The Boot sector comprises all the files which are required to start the
Operating system of the computer. The virus either overwrites the existing program or copies itself to
another part of the disk.
Direct Action Virus – When a virus attaches itself directly to a .exe or .com file and enters the device
while its execution is called a Direct Action Virus. If it gets installed in the memory, it keeps itself
hidden. It is also known as Non-Resident Virus.
Resident Virus – A virus which saves itself in the memory of the computer and then infects other files
and programs when its originating program is no longer working. This virus can easily infect other
files because it is hidden in the memory and is hard to be removed from the system.
Multipartite Virus – A virus which can attack both, the boot sector and the executable files of an
already infected computer is called a multipartite virus. If a multipartite virus attacks your system, you
are at risk of cyber threat.
Overwrite Virus – One of the most harmful viruses, the overwrite virus can completely remove the
existing program and replace it with the malicious code by overwriting it. Gradually it can completely
replace the host’s programming code with the harmful code.
Polymorphic Virus – Spread through spam and infected websites, the polymorphic virus are file
infectors which are complex and are tough to detect. They create a modified or morphed version of the
existing program and infect the system and retain the original code.
File Infector Virus – As the name suggests, it first infects a single file and then later spreads itself to
other executable files and programs. The main source of this virus are games and word processors.
Spacefiller Virus – It is a rare type of virus which fills in the empty spaces of a file with viruses. It is
known as cavity virus. It will neither affect the size of the file nor can be detected easily.
Macro Virus – A virus written in the same macro language as used in the software program and
infects the computer if a word processor file is opened. Mainly the source of such viruses is via emails.
The most suitable way of making your computer virus-free is by installing an Anti-virus software. Such
software help in removing the viruses from the device and can be installed in a computer via two means:
Online download
Buying an Anti-virus software and installing it
Planning a Computer Program :
What is an Algorithm?
Step 1: Start
Step 2: Declare variables num1, num2 and sum.
Step 3: Read values num1 and num2.
Step 4: Add num1 and num2 and assign the result to sum.
sum←num1+num2
Step 5: Display sum
Step 6: Stop
Step 1: Start
Step 2: Declare variables a,b and c.
Step 3: Read variables a,b and c.
Step 4: If a > b
If a > c
Display a is the largest number.
Else
Display c is the largest number.
Else
If b > c
Display b is the largest number.
Else
Display c is the greatest number.
Step 5: Stop
Flowchart :
A flowchart is a diagrammatic representation of an algorithm. A flowchart can be helpful for both writing
programs and explaining the program to others.
2. Find the largest among three different numbers entered by the user.
Rules For Creating Flowchart :
A flowchart is a graphical representation of an algorithm.it should follow some rules while creating a
flowchart
Rule 1: Flowchart opening statement must be ‘start’ keyword.
Rule 2: Flowchart ending statement must be ‘end’ keyword.
Rule 3: All symbols in the flowchart must be connected with an arrow line.
Rule 4: The decision symbol in the flowchart is associated with the arrow line.
Advantages of Flowchart:
Flowcharts are a better way of communicating the logic of the system.
Flowcharts act as a guide for blueprint during program designed.
Flowcharts help in debugging process.
With the help of flowcharts programs can be easily analyzed.
It provides better documentation.
Flowcharts serve as a good proper documentation.
Easy to trace errors in the software.
Easy to understand.
The flowchart can be reused for inconvenience in the future.
It helps to provide correct logic.
Disadvantages of Flowchart:
It is difficult to draw flowcharts for large and complex programs.
There is no standard to determine the amount of detail.
Difficult to reproduce the flowcharts.
It is very difficult to modify the Flowchart.
Making a flowchart is costly.
It makes software processes low.
If changes are done in software, then the flowchart must be redrawn