0% found this document useful (0 votes)
38 views9 pages

Week-1 Basic About Computers

Uploaded by

vedantrathi2006
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views9 pages

Week-1 Basic About Computers

Uploaded by

vedantrathi2006
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Home Week-2

C Programming - Week 1
C Programming - Week 1
What is a Computer?
How Computers Work?
Central Processing Unit (CPU)
Memory Hierarchy in CPU
What is Programming?
Introduction to C Language

What is a Computer?
A computer is an electronic device that processes data, performs calculations, and executes
instructions to carry out various tasks.

It is a versatile and programmable machine that can perform a wide range of functions, from
simple arithmetic operations to complex data analysis and simulations.

Key Components of a Computer:

1. Central Processing Unit (CPU):

Often referred to as the "brain" of the computer.

Responsible for executing instructions and performing calculations.

Composed of control units and arithmetic logic units (ALU).

2. Memory (RAM - Random Access Memory):

Temporary storage used for actively running programs and data.

Data can be read from and written to RAM quickly.

Volatile memory, meaning data is lost when the computer is powered off.

3. Storage Devices:

Store data and programs for long-term use.

Examples include hard drives, solid-state drives (SSDs), and external storage devices.

Non-volatile memory, retaining data even when the computer is turned off.

4. Input Devices:

Allow users to input data and commands into the computer.

Examples include keyboards, mice, touchscreens, and microphones.

5. Output Devices:

Display or present the results of computer processing to users.

Examples include monitors, printers, speakers, and headphones.


6. Motherboard:

The main circuit board that connects and facilitates communication between all
computer components.

7. Software:

Programs and instructions that tell the computer what tasks to perform.

Includes operating systems, applications, and utility software.

How Computers Work?


1. Input Stage:

The process begins with the input of data and instructions.

Input devices such as keyboards, mice, and touchscreens are used to enter data.

Instructions can also come from pre-programmed software.

2. Processing Stage:

Data and instructions are sent to the Central Processing Unit (CPU).

The CPU decodes instructions and performs calculations and logical operations.

It uses memory (RAM) to temporarily store data and intermediate results.

3. Memory Storage:

Data and programs are stored in various types of memory:

RAM (Random Access Memory): Temporary storage used for active processes.

ROM (Read-Only Memory): Permanent storage containing essential system instructions.

Secondary Storage (Hard Drives, SSDs): Long-term storage for files and programs.

4. Control Unit:

The control unit coordinates and manages the execution of instructions.

It fetches instructions from memory, decodes them, and directs the CPU accordingly.

It controls data flow between the CPU and memory.

5. Arithmetic Logic Unit (ALU):

The ALU performs arithmetic operations (addition, subtraction, multiplication, division) and
logical operations (AND, OR, NOT).

These operations manipulate data according to the instructions.

6. Output Stage:

Processed data is sent to output devices for user consumption.

Output devices can include monitors, printers, speakers, and displays.

Users can interact with the computer through output devices.

7. Storage and Retrieval:

Data can be stored on secondary storage devices for long-term preservation.


When needed, data is retrieved from storage and loaded into RAM for processing.

8. Communication:

Computers can communicate with other devices and networks.

This allows data exchange over the internet, LANs, and WANs.

Network interface cards and protocols facilitate communication.

9. Software:

Software consists of programs and instructions that tell the computer what to do.

Operating systems manage hardware resources and enable software to run.

Application software performs specific tasks, such as word processing or gaming.

10. Execution of Programs:

Programs are executed in a step-by-step manner.

The computer fetches, decodes, and executes each instruction.

This process continues until the program is completed.

11. Binary Language:

Computers use binary code (0s and 1s) to represent data and instructions.

The CPU interprets binary code and performs operations accordingly.

Central Processing Unit (CPU)


Definition:

The CPU (Central Processing Unit) is the primary component of a computer responsible for
executing instructions and performing calculations.
Source: WikiPedia

Key Components:

1. Control Unit (CU):

Manages and coordinates the operation of the CPU.

Controls the flow of data and instructions within the CPU and between other hardware
components.

2. Arithmetic Logic Unit (ALU):

Performs mathematical calculations (addition, subtraction, multiplication, division).

Executes logical operations (AND, OR, NOT) for decision-making.

3. Registers:

Small, high-speed memory locations within the CPU.

Store data and instructions temporarily during processing.

Includes the program counter (PC), instruction register (IR), and general-purpose
registers.

Functions:

1. Instruction Execution:

Fetches instructions from memory.

Decodes instructions to determine the operation to be performed.

Executes instructions by performing calculations and data manipulations.

2. Data Processing:

Performs arithmetic and logical operations on data.

Processes data in accordance with the instructions provided by software.

3. Control of Peripherals:
Communicates with input and output devices to manage data transfer.

Controls the timing and synchronization of data exchange.


4. Memory Management:

Accesses and manages data stored in RAM and other memory locations.

Controls memory allocation and deallocation.

Memory Hierarchy in CPU


Introduction:

Memory hierarchy in a CPU refers to the organization of memory units with varying speeds
and capacities, allowing for efficient data access and processing.

This hierarchy is essential for balancing the trade-offs between speed and capacity in modern
computer systems.

Levels of Memory Hierarchy:

1. Registers:

Purpose:

Registers are the smallest and fastest memory units within the CPU.

Usage:

Stores the data that the CPU is actively processing.

Used for holding intermediate results and operands during calculations.

Examples include the program counter (PC) and general-purpose registers (e.g., AX,
BX, etc.).

2. Cache Memory:

Purpose:

Cache memory serves as a bridge between registers and main memory (RAM).
It provides faster access to frequently used data.
3. Main Memory (RAM - Random Access Memory):

Purpose:

Main memory is the primary memory for program and data storage during active
tasks.

It holds the code and data that the CPU is currently processing.

Characteristics:

Faster access times than secondary storage (e.g., hard drives).

Volatile memory, data is lost when the computer is powered off.

4. Secondary Memory (Storage Devices):

Purpose:

Secondary memory provides long-term storage for programs and data, even when
the computer is turned off.

It serves as a large storage pool for files, applications, and the operating system.

Types:

Hard Disk Drives (HDDs): Spinning disks for magnetic data storage.

Solid-State Drives (SSDs): Use flash memory for faster, more durable storage.

Optical Discs (e.g., DVDs, Blu-rays): Used for archiving and software distribution.

USB Drives (Flash Drives): Portable storage for data transfer and backup.

What is Programming?
Programming, also known as coding or software development, is the process of instructing a
computer to perform specific tasks by providing it with a set of structured instructions or
commands in a programming language.

Key Concepts:

1. Programming Languages:

These are formal languages with syntax and semantics used to communicate with
computers.

Examples include C, Python, Java, C++, and JavaScript.

2. Algorithms:

Algorithms are step-by-step sets of instructions used to solve specific problems or


perform tasks.

They form the core of computer programs.

3. Data Structures:
Data structures are ways to organize and store data efficiently, making it easier to
manipulate and access.
4. Software Development Cycle:

Programming involves multiple stages, including problem-solving, coding, testing,


debugging, and maintenance.

Purpose of Programming:

1. Automation:

Programming automates repetitive tasks, improving efficiency and reducing human


error.

2. Problem Solving:

It provides tools to tackle complex problems in various fields, from science and
engineering to finance and entertainment.

3. Creating Software:

Programmers create software applications, from simple scripts to complex software


systems, serving various purposes.

4. Innovation:

Programming drives technological innovation, enabling the development of new


products and services.

Programming Process:

1. Understanding the Problem:

Analyze the problem or task to be solved by the program.

2. Designing the Solution:

Plan the program's structure, algorithms, and data structures.

3. Writing Code:

Implement the solution in a programming language by writing code.

4. Testing and Debugging:

Verify that the program works correctly and fix any errors (bugs).

5. Optimization:

Improve the program's efficiency and performance, if needed.

6. Documentation:

Document the program's functionality, usage, and code for future reference.

Types of Programming:

1. Application Programming:

Developing software applications like word processors, games, and mobile apps.

2. Web Development:

Creating websites and web applications using languages like HTML, CSS, and JavaScript.

3. Embedded Programming:

Programming embedded systems, found in devices like smartphones, IoT devices, and
car systems.
4. Scientific and Data Analysis Programming:

Using programming to analyze and visualize data in scientific research and data science.

Programming Tools:

1. Integrated Development Environments (IDEs):

Software applications that provide a comprehensive development environment with


code editors, debuggers, and build tools.

2. Text Editors:

Simple tools for writing and editing code, often used by experienced programmers.

3. Version Control Systems:

Software like Git helps track changes and manage collaborative coding projects.

Introduction to C Language
C is considered as a middle-level language because it supports the feature of both low-level
and high-level languages. C language program is converted into assembly code, it supports
pointer arithmetic (low-level), but it is machine independent (a feature of high-level).

The C programming language is general-purpose programming language known for its


simplicity, efficiency, and portability.

It was developed in the early 1970s by Dennis Ritchie at Bell Labs for system programming
and has since become one of the most widely used programming languages.

Key Characteristics:

1. Procedural Language:

C follows a procedural programming paradigm, focusing on functions and procedures.

It's known for its structured and modular approach to code.

2. Portability:

C code can be compiled and run on various platforms with minor modifications, making
it highly portable.

3. Efficiency:

C provides low-level memory access and efficient control over hardware, making it
suitable for system programming and performance-critical applications.

4. Strongly Typed:

C enforces strong data typing, meaning data types must be explicitly declared and
adhered to.

5. Rich Standard Library:

C comes with a rich standard library that provides functions for I/O, string manipulation,
memory management, and more.
Basic Syntax:

C code is written in a C source file (usually with a .c extension) and follows a structured syntax
with key elements:

Variables: Used for data storage.

Functions: Blocks of code with a specific purpose.

Control Structures: Statements for making decisions (if-else), loops (for, while), and
branching.

Data Types: int, float, char, etc., to define variable types.

Operators: +, -, *, /, =, etc., for operations on data.

Hello World Example:

1 #include <stdio.h>
2
3 int main() {
4 printf("Hello, World!\n");
5 return 0;
6 }

Advantages of C Language:

1. Efficiency: C allows for precise control over hardware, making it efficient for system
programming and resource-constrained applications.

2. Portability: C programs can be compiled on different platforms with minor adjustments.

3. Vast Community and Resources: C has a large user community, offering extensive
documentation and libraries.

4. Compatibility: Many other languages, like C++, are based on or compatible with C, extending
its capabilities.

Applications:

1. System Programming: C is commonly used for operating system development, embedded


systems, and device drivers.

2. Application Development: It is used to build software applications, including desktop


software and games.

3. Compilers and Interpreters: C is used to create compilers and interpreters for other
programming languages.

4. Scientific and Numerical Computing: In fields like engineering and data analysis.

You might also like