0% found this document useful (0 votes)
57 views7 pages

Computer System Basics and C Programming

A computer system consists of hardware and software working together to process data. Key components include hardware like the CPU, memory, and storage devices, and software like operating systems and application programs. The document also explains algorithms, flowcharts, programming in C, pseudo code, and the functionality of the CPU and memory types.

Uploaded by

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

Computer System Basics and C Programming

A computer system consists of hardware and software working together to process data. Key components include hardware like the CPU, memory, and storage devices, and software like operating systems and application programs. The document also explains algorithms, flowcharts, programming in C, pseudo code, and the functionality of the CPU and memory types.

Uploaded by

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

UNIT :- 1

Q1. What is a Computer System?


* Computer system basically hardware aur software ka ek group hai jo saath mein
kaam karta hai data ko process karne ke liye. Simple words mein, yeh ek team hai
jahan physical parts (hardware) instructions (software) follow karte hain kaam
karne ke liye.
Key Components:
1. Hardware:
o Yeh woh physical parts hain jinko aap touch kar sakte ho. Briefly:
* CPU (Central Processing Unit):
* Computer ka "brain." Yeh calculations karta hai aur instructions execute karta
hai.
* Memory (RAM - Random Access Memory):
* Temporary storage data ke liye jo CPU actively use kar raha hai. Yeh fast hai
lekin volatile hai (computer band hone par data loss ho jata hai).
* Storage Devices (Hard Drives, SSDs):
* Permanent storage data aur programs ke liye. Yeh data retain karte hain computer
band hone par bhi.
* Input Devices (Keyboard, Mouse, etc.):
* Aapko data aur commands computer mein enter karne dete hain.
* Output Devices (Monitor, Printer, etc.):
* Processing ke results dikhate ya produce karte hain.
2. Software:
o Yeh woh programs aur instructions hain jo hardware ko batate hain kya karna hai.
Key types:
* Operating System (OS):
* Hardware aur software resources manage karta hai. Examples: Windows, macOS,
Linux.
* Application Software:
* Specific tasks ke liye designed programs. Examples: Word processors, web
browsers, games.
Simple terms mein:
* Aap input devices use karte ho computer ko data dene ke liye.
* CPU woh data process karta hai, RAM temporary storage ke liye use karte hue.
* Storage devices data permanently rakhte hain.
* Output devices aapko results dikhate hain.
* Operating system aur application software yeh sab possible banate hain.
Q2. what is flowchart and algorithm
Okay, flowchart aur algorithm kya hote hain, samajhte hain:
Algorithm:
* Algorithm basically ek step-by-step procedure hota hai kisi problem ko solve
karne ke liye.
* Yeh ek set of instructions hota hai jo computer ya koi bhi system follow karta
hai specific task perform karne ke liye.
* Simple words mein, yeh ek recipe ki tarah hai, jismein har ingredient aur step
clearly defined hota hai.
* Example: Agar aapko chai banana hai, toh uska ek algorithm hoga:
o Pehle paani garam karo.
o Phir chai patti aur sugar daalo.
o Phir doodh daalo.
o Phir thodi der ubaalo.
o Phir serve karo.
Flowchart:
* Flowchart algorithm ka graphical representation hota hai.
* Yeh visual diagrams hote hain jo algorithm ke steps aur flow ko dikhate hain.
* Ismein different shapes use hote hain, jaise ki:
o Rectangle (process)
o Diamond (decision)
o Oval (start/end)
o Arrows (flow direction)
* Flowchart se algorithm ko samajhna aur follow karna easy ho jata hai.
* Example: Chai banane ka algorithm flowchart mein kuch aisa dikhega:
o Oval (start)
o Rectangle (paani garam karo)
o Rectangle (chai patti aur sugar daalo)
o Diamond (doodh dalna hai?)
* yes - Rectangle (doodh daalo)
* no - rectangle (skip doodh)
o Rectangle (ubaalo)
o Rectangle (serve karo)
o Oval (end)
Basically:
* Algorithm ek written plan hai.
* Flowchart us plan ka visual diagram hai.
Dono hi programming aur problem-solving mein bahut useful hote hain.
Q3.write algorithm with flowchart to calculate area of a circle ?
Okay, circle ka area calculate karne ke liye algorithm aur flowchart:
Algorithm:
1. Start
2. Input radius (r) of the circle.
3. Calculate area (area) using the formula: area = ? * r * r (where ? ? 3.14159).
4. Output area.
5. End
Flowchart:
+----------+
| Start |
+----------+
|
v
+----------+
| Input r |
+----------+
|
v
+-----------------+
| area = ? * r * r |
+-----------------+
|
v
+-----------+
| Output area |
+-----------+
|
v
+----------+
| End |
+----------+
Explanation:
* Start/End (Oval): Flowchart ka starting aur ending point.
* Input r (Rectangle): User se circle ka radius input lena.
* area = ? * r * r (Rectangle): Area calculate karna, ? (pi) ki value approximately
3.14159 use karke.
* Output area (Rectangle): Calculated area ko display karna.
Hinglish Explanation:
* Pehle "Start" karo.
* User se circle ka "radius" (r) input lo.
* Formula "area = ? * r * r" use karke area calculate karo. Yahan ? ki value
3.14159 le sakte ho.
* Calculated "area" ko dikhao.
* Phir "End" karo.
Q4. What do you mean by program? Explain programming in c briefly.
What is a Program?
* Basically, a program is a set of instructions that a computer follows to perform
a specific task.
* Think of it like a recipe for a computer. It tells the computer exactly what to
do, step by step.
* Programs are written in programming languages, which are like special languages
that computers understand.
Programming in C Briefly:
* C is a powerful and versatile programming language. It's been around for a long
time and is still widely used.
* It's known for its efficiency and control, which makes it great for system
programming, embedded systems, and more.
* Here are some key things about C programming:
o Structure: C programs are typically organized into functions. A function is a
block of code that performs a specific task. The main() function is where the
program starts executing.
o Variables: Variables are used to store data. You need to declare the type of data
a variable will hold (e.g., integer, floating-point number, character).
o Data Types: C has various data types, such as int (integers), float (floating-
point numbers), char (characters), and more.
o Operators: C uses operators to perform operations on data (e.g., arithmetic
operators, comparison operators).
o Control Flow: C provides control flow statements like if-else, for loops, and
while loops to control the execution of the program.
o Functions: C allows you to create your own functions to break down complex tasks
into smaller, manageable pieces.
o Pointers: C is famous for its pointers, which are variables that store memory
addresses. This gives you a lot of control over memory management.
o Compilation: C programs need to be compiled before they can be executed. A
compiler translates the C code into machine code that the computer can understand.
Simple C Program Example:
C
#include <stdio.h>

int main() {
printf("Hello, world!\n");
return 0;
}
Hinglish Explanation:
* "Program" matlab instructions ka ek set, jo computer follow karta hai ek specific
kaam karne ke liye.
* C ek powerful programming language hai.
* C programs functions mein organized hote hain. main() function se program start
hota hai.
* Variables data store karne ke liye hote hain.
* C mein int, float, char jaise data types hote hain.
* Operators calculations aur comparisons ke liye use hote hain.
* if-else, for, while jaise control flow statements program ke execution ko control
karte hain.
* C pointers provide memory management capabilities.
* C program ko compile karna padta hai machine code me convert karne ke liye.
* Example program "Hello world" print karta hai.
Structure:-
A C program typically follows a specific structure, which helps organize the code
and makes it easier to understand. Here's a general outline:
1. Preprocessor Directives:
* These lines start with a # symbol.
* They provide instructions to the preprocessor, which modifies the code before
compilation.
* Common directives include:
o #include <header_file.h>: Includes header files that contain function
declarations and other definitions. For example, #include <stdio.h> includes
standard input/output functions.
o #define: Creates macros, which are symbolic names for constants or code snippets.
2. Global Declarations:
* These are declarations of variables and functions that are accessible from
anywhere in the program.
* Global variables are declared outside of any function.
3. main() Function:
* This is the entry point of the program. Execution begins here.
* It's a function with a return type (usually int).
* The main() function contains the main logic of the program.
4. Function Definitions (Other Functions):
* These are blocks of code that perform specific tasks.
* They can be called from the main() function or from other functions.
* Each function has a return type, a name, and a list of parameters (if any).
5. Statements and Expressions:
* These are the instructions that the computer executes.
* Statements can be declarations, assignments, control flow statements (e.g., if,
for, while), or function calls.
* Expressions are combinations of variables, constants, and operators that evaluate
to a value.
Example Structure:
C
#include <stdio.h> // Preprocessor directive

// Global variable declaration


int globalVariable = 10;

// Function declaration (prototype)


int addNumbers(int a, int b);

int main() { // main function


int num1 = 5;
int num2 = 7;
int sum;

sum = addNumbers(num1, num2); // Function call

printf("Sum: %d\n", sum);

return 0; // Return statement


}

// Function definition
int addNumbers(int a, int b) {
return a + b;
}
Hinglish Explanation:
* Preprocessor Directives: # se shuru hote hain. Header files include karne ke
liye.
* Global Declarations: Variables aur functions jo program mein kahin bhi use ho
sakte hain.
* main() Function: Program ka starting point. Yahan se execution shuru hota hai.
* Function Definitions: Specific kaam karne ke liye code blocks.
* Statements and Expressions: Instructions jo computer execute karta hai.
Example ko samajhte hain:
* #include <stdio.h>: stdio.h file ko include karta hai, jismein printf() function
defined hai.
* int globalVariable = 10;: Ek global variable declare kiya hai.
* int addNumbers(int a, int b);: addNumbers function ka prototype declare kiya hai.
* int main(): Main function hai.
* int num1 = 5; int num2 = 7; int sum;: Local variables declare kiye gaye hain.
* sum = addNumbers(num1, num2);: addNumbers function ko call kiya hai aur result
sum mein store kiya hai.
* printf("Sum: %d\n", sum);: Sum ko print kiya hai.
* return 0;: Program ko successfully end kiya hai.
* int addNumbers(int a, int b) { return a + b; }: addNumbers function define kiya
hai, jo do numbers ko add karta hai.

Q5. What is pseudo code? Write a pseudo code for addition of two integers.
What is Pseudo Code?
* Pseudo code is like a simplified, human-readable way to describe an algorithm.
* It's not a real programming language, so it doesn't have strict syntax rules.
* It's used to plan and outline the logic of a program before writing it in a
specific programming language.
* Think of it as a rough draft of your code, written in plain English (or Hinglish,
in our case).
* It helps you focus on the logic without worrying about the details of a
particular programming language.
Pseudo Code for Addition of Two Integers:
START
INPUT number1
INPUT number2
SUM = number1 + number2
OUTPUT SUM
END
Hinglish Explanation:
* START: Shuru karo.
* INPUT number1: Pehla number input karo.
* INPUT number2: Dusra number input karo.
* SUM = number1 + number2: Dono numbers ko jodo aur result ko SUM mein store karo.
* OUTPUT SUM: SUM ko dikhao.
* END: Khatam karo.
More Detailed Pseudo Code Example:
START
DISPLAY "Enter the first integer:"
INPUT integer1
DISPLAY "Enter the second integer:"
INPUT integer2
total = integer1 + integer2
DISPLAY "The sum is:"
DISPLAY total
END
Hinglish detailed explanation:
* START: Shuru karo.
* DISPLAY "Enter the first integer:": Screen pe dikhao "Pehla integer enter karo:".
* INPUT integer1: Pehla integer input karo aur integer1 mein store karo.
* DISPLAY "Enter the second integer:": Screen pe dikhao "Dusra integer enter
karo:".
* INPUT integer2: Dusra integer input karo aur integer2 mein store karo.
* total = integer1 + integer2: integer1 aur integer2 ko jodo aur total mein store
karo.
* DISPLAY "The sum is:": Screen pe dikhao "Sum hai:".
* DISPLAY total: total ki value screen pe dikhao.
* END: Khatam karo.
Pseudo code is a great tool for planning your programs and making sure you
understand the logic before you start coding.
Q6. What is CPU? Explain the functionality of CPU.
Okay, CPU ke baare mein baat karte hain:
What is CPU?
* CPU ka full form hai Central Processing Unit.
* Yeh computer ka "brain" hota hai.
* Yeh computer ke sabhi instructions aur calculations ko process karta hai.
* Basically, yeh woh component hai jo computer ko "sochne" aur "kaam karne" ki
ability deta hai.
Functionality of CPU:
CPU ke main functions yeh hain:
1. Fetching Instructions:
o CPU memory se instructions fetch karta hai.
o Yeh instructions program ke code se aate hain.
2. Decoding Instructions:
o CPU fetched instructions ko decode karta hai.
o Decoding ka matlab hai instructions ko samajhna ki kya karna hai.
3. Executing Instructions:
o CPU decoded instructions ko execute karta hai.
o Yeh calculations, data transfer, aur other operations include karta hai.
4. Storing Results:
o CPU executed instructions ke results ko memory mein store karta hai.
CPU ke main parts:
* Arithmetic Logic Unit (ALU):
o Yeh calculations (addition, subtraction, etc.) aur logical operations
(comparisons) karta hai.
* Control Unit (CU):
o Yeh CPU ke sabhi operations ko control karta hai.
o Yeh instructions fetch, decode, aur execute karne ke process ko manage karta hai.
* Registers:
o Yeh small, high-speed memory locations hote hain jo CPU ke andar hote hain.
o Yeh temporary data aur instructions store karte hain.
Hinglish Explanation:
* CPU computer ka dimag hai.
* Yeh instructions fetch karta hai, matlab memory se instructions leta hai.
* Phir instructions ko decode karta hai, matlab samajhta hai ki kya karna hai.
* Phir instructions ko execute karta hai, matlab kaam karta hai.
* Phir results ko memory mein store karta hai.
* ALU calculations karta hai, CU control karta hai, aur registers temporary data
store karte hain.
Q7. What is memory? Explain with types of memory.
What is Memory?
* Memory computer ka woh hissa hai jahan data aur instructions temporary ya
permanent store hote hain.
* Yeh computer ko information yaad rakhne aur use karne mein help karta hai.
* Simple words mein, yeh computer ka "yaad karne wala" part hai.
Types of Memory:
1. Primary Memory (Main Memory):
o Yeh CPU directly access karta hai.
o Yeh fast hota hai, lekin volatile (data power off hone par loss ho jata hai).
o Types:
* RAM (Random Access Memory):
* Yeh temporary storage hai.
* CPU active programs aur data ko RAM mein store karta hai.
* Types:
* DRAM (Dynamic RAM): Sabse common type, cheap, lekin refresh karna padta hai.
* SRAM (Static RAM): Fast, expensive, refresh nahi karna padta. Cache memory mein
use hota hai.
* ROM (Read-Only Memory):
* Yeh permanent storage hai.
* Computer start hone ke liye essential instructions store karta hai.
* Data sirf read kar sakte hain, write nahi.
* Types:
* PROM (Programmable ROM): Ek baar program kar sakte hain.
* EPROM (Erasable PROM): UV light se erase kar sakte hain.
* EEPROM (Electrically Erasable PROM): Electrically erase kar sakte hain.
2. Secondary Memory (Storage):
o Yeh permanent storage hai, CPU directly access nahi karta.
o Yeh slow hota hai, lekin non-volatile (data power off hone par loss nahi hota).
o Types:
* Hard Disk Drive (HDD): Magnetic disks use karta hai.
* Solid State Drive (SSD): Flash memory use karta hai, fast hota hai.
* USB Drives: Portable storage.
* Optical Drives (CD, DVD, Blu-ray): Laser se data read/write karta hai.
Hinglish Explanation:
* Memory computer ka yaad karne wala part hai.
* Primary memory fast hota hai, lekin temporary hota hai.
o RAM active data store karta hai.
o ROM start-up instructions store karta hai.
* Secondary memory permanent hota hai, lekin slow hota hai.
o HDD, SSD, USB drives, aur optical drives secondary memory ke examples hain.

You might also like