Introduction to computing
Computing is an operation that involves processing of data by making use of a computer
Computer:
A computer is an electronic device that can store, process, and retrieve data. It follows a set of instructions (called programs) to perform tasks like calculations, storing
files, playing music, etc.
.
Components of a Computer
A computer system is made up of hardware and software. Both are essential for the computer to work properly.
🧱 1. Hardware
Hardware refers to all the physical components of the computer system – the parts you can see, touch, and feel.
✅ Types of Hardware Components:
🔹 a. Input Devices
These are devices that help users enter data and instructions into the computer.
Examples:
Keyboard – To type text and commands.
Mouse – To select and click on-screen items.
Scanner – To scan physical documents into the computer.
Microphone – To input voice.
🔹 b. Output Devices
These are devices that display the result of processing to the user.
Examples:
Monitor (Screen) – Shows visual output.
Printer – Gives printed output on paper.
Speakers – Gives audio output.
🔹 c. Central Processing Unit (CPU)
The CPU is called the "brain" of the computer. It performs all calculations and decision-making.
It has two main parts:
ALU (Arithmetic Logic Unit):
Performs arithmetic operations (add, subtract, etc.) and logical operations (comparison like >, <, ==).
CU (Control Unit):
Controls all the operations of the computer. It tells other parts what to do.
CPU executes the instructions given in a program.
🔹 d. Memory / Storage Devices
Memory stores data either temporarily or permanently.
i. Primary Memory:
RAM (Random Access Memory)
Temporary memory – stores data while programs are running. It is volatile (data is lost when the computer turns off).
ROM (Read Only Memory)
Permanent memory – stores system boot information. It is non-volatile.
ii. Secondary Memory:
Used for permanent storage of data.
Examples:
Hard Disk Drive (HDD)
Solid State Drive (SSD)
Pen Drive
CD/DVD
💿 2. Software
Software is a set of instructions (programs) that tell the hardware what to do. You cannot touch software, but you can see it working on your screen.
✅ Types of Software:
🔹 a. System Software
It manages the hardware and system resources.
Examples:
Operating Systems like Windows, Linux, macOS.
Device Drivers – Help the hardware (like printer, mouse) work with the system.
Utility Programs – Backup tools, antivirus software, etc.
🔹 b. Application Software
It helps users perform specific tasks.
Examples:
MS Word – For typing documents.
Excel – For calculations.
Web Browser – To access the internet (like Chrome, Firefox).
Games – Like PUBG, Chess, etc.
🔁 3. Functional Units of a Computer
These components work together to perform the Input–Processing–Output (IPO) cycle.
Component Function
Input Unit Takes data from user
Processing Unit CPU processes the input
Memory Unit Stores data temporarily or permanently
Output Unit Displays result to user
Storage Devices Saves data for future use
📝 Conclusion
A computer works by:
1. Taking input
2. Processing it using CPU
3. Storing it in memory
4. Giving output using output devices
It needs both hardware (body) and software (soul) to work efficiently.
💡 Concept of Hardware and Software
A computer system is made up of two major parts:
🔹 1. Hardware
🔹 2. Software
They work together to make the computer function.
Let’s understand each of them clearly:
🧱 1. Hardware – The Physical Components
Hardware refers to all the physical parts of a computer.
These are the parts that you can see, touch, and feel.
Hardware does not work on its own. It needs instructions from software.
✅ Examples of Hardware:
Input Devices: Keyboard, Mouse, Scanner, Camera
Output Devices: Monitor, Printer, Speakers
Storage Devices: Hard Disk, Pen Drive, SSD
Processing Unit: CPU (Central Processing Unit)
Other Components: RAM, Motherboard, Power Supply
📌 Without software, hardware is useless. It just sits there doing nothing.
💻 2. Software – The Set of Instructions
Software is a collection of programs or instructions that tell the hardware what to do.
It is not physical – you cannot touch it, but you can see and use it.
Software gives life to the hardware.
✅ Types of Software:
🔸 a. System Software
Helps the computer run and manage its hardware.
Operating System (OS): Windows, Linux, macOS
Device Drivers: Helps hardware (like printer, USB, etc.) work properly
Utility Programs: Antivirus, Disk cleanup tools
🔸 b. Application Software
Helps users do specific tasks.
Word Processors: MS Word
Spreadsheet Software: MS Excel
Browsers: Google Chrome, Firefox
Games: PUBG, Candy Crush
📌 Without hardware, software cannot run. It needs a machine to operate on.
🔁 Relationship Between Hardware and Software
Hardware Software
Physical part of a computer Set of instructions/programs
Hardware Software
Can be touched Cannot be touched
Cannot work without software Cannot run without hardware
Examples: Monitor, Keyboard, CPU Examples: MS Word, Windows OS, Chrome
🧠 Simple Analogy:
Think of hardware as the body, and software as the soul (mind).
Both are needed to make a person (computer) alive and functional.
🎨 Art of Programming through Algorithms and Flowcharts
Programming is not just about writing code. It involves thinking, planning, and solving problems step by step.
The “Art of Programming” means:
Designing logical steps to solve a problem using simple tools like algorithms and flowcharts before writing code.
🔹 1. What is an Algorithm?
An algorithm is a step-by-step procedure to solve a problem.
✅ Characteristics of a Good Algorithm:
Clear and unambiguous (no confusion)
Has a beginning and an end
Takes input and produces output
Step-by-step and easy to follow
Efficient (uses minimum time and memory)
📌 Example Algorithm: Add Two Numbers
vbnet
CopyEdit
Step 1: Start
Step 2: Read two numbers A and B
Step 3: Add A and B → store in SUM
Step 4: Display SUM
Step 5: Stop
This is how you think logically before coding in C.
🔹 2. What is a Flowchart?
A flowchart is a diagram that shows the steps of an algorithm using symbols.
It helps:
Visualize the logic
Understand the process
Communicate ideas clearly before coding
✅ Common Flowchart Symbols:
Symbol Meaning Shape
🔷 Start / Stop Oval
🔲 Process / Action Rectangle
🔺 Input / Output Parallelogram
🔽 Decision (Yes/No) Diamond
➡️ Flow direction Arrow
📌 Flowchart Example: Add Two Numbers
mathematica
CopyEdit
🔷 Start
↓
🔺 Input A, B
↓
🔲 SUM = A + B
↓
🔺 Print SUM
↓
🔷 Stop
This makes it easy to convert the logic into C code later.
✅ Why Use Algorithms and Flowcharts?
Algorithms Flowcharts
Written in simple English steps Drawn using symbols and arrows
Easy to convert into code Easy to understand the flow of logic
Great for thinking and planning Great for visualizing and presenting
. C Program (Actual code using C language)
After designing the logic using algorithm and flowchart, you write the program in C.
📌 Example C Code:
c
CopyEdit
#include <stdio.h> // Preprocessor directive
int main() {
int a, b, sum; // Variable declaration
printf("Enter two numbers: ");
scanf("%d %d", &a, &b); // Input
sum = a + b; // Logic (Process)
printf("Sum = %d", sum); // Output
return 0; // End of program
}
What is C Programming?
C programming is a high-level programming language used to write software programs.
It was developed in 1972 by Dennis Ritchie at Bell Laboratories, USA.
It is known as the “mother of all programming languages” because many other languages (like C++, Java, Python) are influenced by C.
🌟 📘 The Story of How C Was Born
🔹 Once upon a time, in the land of Computers...
In the 1960s, a group of smart scientists invented a language called ALGOL.
ALGOL was like the grandfather of programming – very strict and organized. He taught people how to structure their code neatly, like building blocks in a tower.
🔹 A few years later…
In 1967, Martin Richards wanted a simpler tool to help write software.
So, he created BCPL (Basic Combined Programming Language).
Think of BCPL as ALGOL’s son – smart and strong, but easier to understand.
🔹 Then came B...
In 1970, a clever man named Ken Thompson worked on an operating system called UNIX.
He thought BCPL was a bit heavy, so he made a smaller version and called it B – just the first letter!
B was fast and perfect for small systems.
🔹 But B wasn’t strong enough...
In 1972, another brilliant man, Dennis Ritchie, realized that B needed to grow up.
So, he took B and made it more powerful and flexible.
And that’s how C was born! 🎉
Dennis used C to rewrite the entire UNIX operating system – that made C very famous!
🔹 C becomes popular!
In 1978, two authors, Kernighan and Ritchie, wrote a book called
"The C Programming Language".
This book became a bestseller, and C became popular all over the world.
So that version was called K&R C.
🔹 But there was a problem…
Different people used slightly different versions of C – some commands worked in one place, but not in another. This confused programmers! 😕
So in 1983, a group called ANSI (American National Standards Institute) stepped in.
They created one standard version of C for everyone to use – this was called ANSI C, finalized in 1989.
🔹 Then came an upgrade – C99
In 1999, C got some new features like:
Declaring variables anywhere
Inline functions
Better number support
This version was called C99.
C Language Evolution Timeline:
Yea Language Developer / Committee Notes
r
196 ALGOL International Group Introduced structured programming; base for future languages
0
196 BCPL Martin Richards Used for system software development
7
197 B Language Ken Thompson Simplified version of BCPL, used in early UNIX systems
0
197 C Language Dennis Ritchie (Bell Labs) Developed to rewrite the UNIX OS in a better way
2
197 K&R C Kernighan & Ritchie First book published: The C Programming Language
8
198 ANSI C ANSI Committee Standard version to solve compatibility issues
3
198 ANSI/ISO C ISO Committee International Standard version
9
199 C99 Standardization Committee Added new features (like inline functions, variable
9 declarations)
Importance of C
1. Fast and Efficient:
C programs run very fast due to its rich set of data types and powerful operators. It is much faster than older languages like BASIC.
2. Built-in Functions and Libraries:
C has more than 60 keywords and many built-in functions that make programming easier and more powerful.
3. Portability:
C programs can be run on different computers or operating systems with little or no modification.
4. Structured and Modular:
C supports modular programming, allowing large programs to be divided into smaller functions or modules. This helps in debugging and maintenance.
5. Extensibility:
Programmers can create and add their own functions to the C library, which allows customization and flexibility.
💻 Sample Program in C
Let's take the simplest C program that says "Hello, Meena!" on the screen:
c
CopyEdit
#include <stdio.h>
int main() {
printf("Hello, Meena!");
return 0;
}
🧠 Let's Explain Line by Line:
🔹 #include <stdio.h>
Think of this like calling a helper book that knows how to print and take input.
Without this, the computer won’t understand what printf means.
🧊 Real life: You bring a calculator to do math — here, you're bringing the “print helper”.
🔹 int main()
This is like starting point of your task.
Just like when you start cooking or writing, every C program begins here.
🧊 Think: “Start following my instructions now!”
🔹 { ... }
These curly brackets are like a box.
Whatever instructions you put inside this box will be done by the computer.
🔹 printf("Hello, Meena!");
This is the actual instruction:
“Hey computer, show this message on the screen!”
🧊 It’s like saying: “Say Hello to Meena!”
🔹 return 0;
This means:
“I’m done. No errors. All okay.”
🧊 Like saying “Mission Complete” to the system.
Output:
CopyEdit
Hello, Meena!
✅ Simple C Program – Add Two Numbers
c
CopyEdit
#include <stdio.h>
int main() {
int a = 5, b = 3;
printf("%d", a + b);
return 0;
}
Output:
CopyEdit
8
✅ Simple Interest Program in C
c
CopyEdit
#include <stdio.h>
int main() {
float p = 1000, r = 5, t = 2;
float si;
si = (p * r * t) / 100;
printf("Simple Interest = %.2f", si);
return 0;
}
📘 Explanation:
p = 1000 → Principal amount
r = 5 → Rate of interest (% per year)
t = 2 → Time in years
si → Result of simple interest using formula:
SI=P×R×T100\text{SI} = \frac{P \times R \times T}{100}SI=100P×R×T
Output:
java
CopyEdit
Simple Interest = 100.00
✅ Simple C Program Using sqrt() with int
c
CopyEdit
#include <stdio.h>
#include <math.h>
int main() {
int num = 16;
double result = sqrt(num);
printf("Square root = %.0f", result);
return 0;
}
🧠 Explanation:
int num = 16; → We're using an integer value.
sqrt(num) → Finds the square root. It returns a double, so we store it in a double variable.
%.0f → Prints the result without decimal places.
Output:
java
CopyEdit
Square root = 4
🔹 1.8 BASIC STRUCTURE OF C PROGRAMS (Detailed Explanation)
A C program is made of different sections, like building blocks. Each section has a job. Here's a detailed explanation of each one:
🔸 1. Documentation Section
This part includes comments.
Comments are written with // or /* ... */
It explains what the program does, who wrote it, date, etc.
Not required by the compiler, but very helpful for humans to understand the program.
c
CopyEdit
// Program to add two numbers
🔸 2. Link Section
Used to link built-in C libraries to your program.
Example: #include <stdio.h> – tells the compiler to use the standard input/output functions like printf() or scanf().
c
CopyEdit
#include <math.h> // for math functions like sqrt, pow, etc.
🔸 3. Definition Section
This section defines constants using #define.
You give names to values so they can be reused easily.
c
CopyEdit
#define PI 3.14
🔸 4. Global Declaration Section
If you want to use a variable in all functions, declare it here.
These are called global variables.
c
CopyEdit
int total = 0; // This variable can be used in all functions
🔸 5. main() Function Section
This is the starting point of any C program.
Without main(), your program won’t run.
It has two parts:
o Declaration part: Where you declare your variables.
o Executable part: Where you write actual logic (statements).
c
CopyEdit
int main() {
int a = 10, b = 20; // Declaration
int sum = a + b; // Executable
printf("%d", sum);
return 0;
}
🔸 6. Subprogram Section (User-defined Functions)
You can create your own functions outside main() for reuse.
c
CopyEdit
void greet() {
printf("Hello!");
}
📌 Summary Diagram:
csharp
CopyEdit
Documentation
Link
Definition
Global Declarations
main()
{
Declaration
Executable
}
Subprograms (Functions)
🔹 1.9 PROGRAMMING STYLE (Detailed Explanation)
C is a free-form language, which means:
You can write the code on one line or multiple lines.
But good style is important for clarity and understanding.
✅ Good Programming Practices:
1. Use lowercase letters
C keywords like int, main, return must be lowercase.
Variable names should also be lowercase.
2. Use proper indentation
Keep your code neatly aligned so it’s easy to read.
c
CopyEdit
int main() {
int a = 10;
printf("%d", a);
return 0;
}
3. Use braces {} properly
Always use braces to group statements, even if there's only one line.
Write opening and closing braces on their own lines (recommended).
4. Write one statement per line
Don’t write everything in one line.
c
CopyEdit
int a = 5;
int b = 10;
int sum = a + b;
5. Use comments generously
Add comments to explain logic.
c
CopyEdit
// This program calculates area of a circle