CHAPTER 1: INTRODUCTION TO COMPUTERS AND
PROGRAMMING
1. WHAT IS A COMPUTER?
1.1 Definition of a Computer
A computer is an electronic machine that is designed to accept data, process that data
according to given instructions, store information, and produce meaningful results as
output.
In very simple words, a computer is a thinking machine that does exactly what humans tell it to
do, but very fast and very accurately.
1.2 Why Computers Exist
Computers exist because humans needed a machine that can:
●
●
●
●
●
Perform calculations faster than humans
Store large amounts of information
Repeat tasks without getting tired
Reduce human errors
Solve complex problems
Before computers, humans used paper, pen, and mechanical machines. These were slow,
error-prone, and limited.
1.3 Where Computers Are Used
Computers are used almost everywhere, including:
●
●
●
●
Homes (mobile phones, laptops)
Schools and colleges
Banks and financial institutions
Hospitals and medical labs
●
●
●
●
●
Factories and industries
Space research
Government offices
Traffic control systems
Internet and communication
1.4 When Computers Are Used
Computers are used when:
●
●
●
●
●
A task requires speed
A task requires accuracy
A task requires large data handling
A task needs automation
A task is repetitive
1.5 Advantages of Computers
●
●
●
●
●
Very fast processing speed
High accuracy
Can store massive data
Can work continuously without rest
Can perform multiple tasks
1.6 Disadvantages of Computers
●
●
●
●
●
Cannot think on their own
Fully dependent on instructions
Needs electricity
Can be misused
No emotions or intelligence
1.7 Real-Life Analogy
Think of a computer as a very obedient servant:
● You must tell it exactly what to do
● It will never argue
● It will never think
● It will only follow instructions
2. HARDWARE VS SOFTWARE
2.1 What is Hardware?
Hardware refers to all physical parts of a computer that you can see and touch.
Examples of Hardware
●
●
●
●
●
●
●
●
Keyboard
Mouse
Monitor
CPU (Central Processing Unit)
Hard disk
RAM
Printer
Speakers
2.2 Why Hardware Exists
Hardware exists to:
●
●
●
●
Take input
Process data
Store data
Show output
Without hardware, a computer cannot exist physically.
2.3 What is Software?
Software is a set of programs or instructions that tells the hardware what to do.
Software cannot be touched. It exists in digital form.
2.4 Why Software Exists
Software exists because:
● Hardware cannot work on its own
● Hardware needs instructions
● Instructions must be written in a language the computer understands
2.5 Relationship Between Hardware and Software
●
●
●
●
Hardware is the body
Software is the brain
Hardware without software is useless
Software without hardware cannot run
2.6 Real-Life Analogy
●
●
●
●
Hardware is like a TV
Software is like the TV channel
Without channel, TV shows nothing
Without TV, channel cannot be seen
3. TYPES OF SOFTWARE
3.1 System Software
System software controls the basic functioning of a computer.
Examples
● Operating System (Windows, Linux, macOS)
● Device drivers
● Firmware
Purpose
●
●
●
●
Manage hardware
Control memory
Manage files
Run applications
3.2 Application Software
Application software helps users perform specific tasks.
Examples
●
●
●
●
●
Microsoft Word
Excel
Browser
Games
Media players
3.3 Utility Software
Utility software helps maintain and protect the system.
Examples
● Antivirus
● Disk cleaner
● Backup tools
4. WHAT IS PROGRAMMING?
4.1 Definition of Programming
Programming is the process of writing instructions that tell a computer what to do, how to
do, and when to do.
4.2 Why Programming Exists
Programming exists because:
● Computers do not understand human language
● Instructions must be written in a special format
● Tasks must be automated
4.3 Where Programming is Used
●
●
●
●
●
●
●
Software development
Websites
Mobile apps
Games
Embedded systems
Artificial intelligence
Robotics
4.4 When Programming is Used
Programming is used when:
●
●
●
●
Tasks are repetitive
Tasks are complex
Automation is required
Accuracy is important
4.5 Real-Life Analogy
Programming is like writing a cooking recipe:
● Step-by-step instructions
● Exact order
● No missing steps
5. WHAT IS A PROGRAMMING LANGUAGE?
5.1 Definition
A programming language is a formal language used to write instructions that a computer can
execute.
5.2 Why Programming Languages Exist
Programming languages exist because:
● Computers understand only binary
● Humans need readable instructions
● Translation is required between human and machine
5.3 Types of Programming Languages
● Low-Level Languages
● High-Level Languages
6. LOW-LEVEL VS HIGH-LEVEL LANGUAGES
6.1 Low-Level Languages
Low-level languages are close to machine hardware.
Types
● Machine Language
● Assembly Language
Characteristics
●
●
●
●
Fast execution
Hardware dependent
Difficult to learn
Error-prone
6.2 High-Level Languages
High-level languages are close to human language.
Examples
●
●
●
●
C
C++
Java
Python
Characteristics
●
●
●
●
Easy to learn
Portable
Slower than low-level
Human-readable
7. COMPILER VS INTERPRETER
7.1 Compiler
A compiler translates the entire program into machine code at once.
Advantages
● Faster execution
● Errors found before running
Disadvantages
● Debugging difficult
● Compilation time
7.2 Interpreter
An interpreter translates the program line by line.
Advantages
● Easy debugging
● Immediate execution
Disadvantages
● Slower execution
● Errors appear during runtime
8. WHAT IS C LANGUAGE?
8.1 Definition
C is a high-level programming language that allows direct hardware access and structured
programming.
8.2 Why C Language Exists
C was created to:
● Develop operating systems
● Write fast programs
● Control hardware
8.3 Where C Is Used
●
●
●
●
●
Operating systems
Embedded systems
Compilers
Device drivers
System software
9. HISTORY OF C LANGUAGE
●
●
●
●
Developed by Dennis Ritchie
Developed in 1972
Developed at Bell Laboratories
Initially created to develop UNIX OS
10. FEATURES OF C LANGUAGE
●
●
●
●
●
●
Simple syntax
Fast execution
Portable
Structured programming
Low-level access
Efficient memory usage
11. APPLICATIONS OF C LANGUAGE
●
●
●
●
●
Operating systems
Embedded systems
Game engines
Database systems
Networking software
12. STRUCTURE OF A C PROGRAM
Basic Structure
#include <stdio.h>
int main() {
printf("Hello World");
return 0;
}
Explanation of Each Part
● #include tells compiler to include library
● <stdio.h> provides input-output functions
● int specifies return type
● main() is entry point
● { } define block
● printf prints output
● return 0 ends program
13. INSTALLING C COMPILER (GCC)
GCC—>
GCC stands for GNU Compiler Collection.
Purpose
● Converts C code to machine code
14. WRITING FIRST C PROGRAM
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
Line-by-Line Explanation
● #include <stdio.h> includes standard input-output
● int main() starts program
● printf() prints text
● return 0; returns success
15. COMPILATION PROCESS IN C
Steps
1. Source code written
2. Preprocessing
3. Compilation
4. Linking
5. Execution
16. ERRORS IN C
16.1 Syntax Errors
Errors due to wrong grammar.
Example:
printf("Hello")
16.2 Runtime Errors
Errors during execution.
Example:
Division by zero
16.3 Logical Errors
Wrong output due to wrong logic.
Example:
Wrong formula…….
COMMON BEGINNER MISTAKES
● Missing semicolon
● Forgetting brackets
● Wrong data types
● Not understanding compilation
INTERVIEW QUESTIONS
● What is C language?
● Difference between compiler and interpreter?
● Types of errors in C?
PRACTICE QUESTIONS
1. Define computers.
2. Explain hardware and software.
3. Write structure of C program.
REAL-WORLD USE CASES
● Operating systems
● Microcontrollers
● Embedded devices