Full Transcript

## Fundamentals of Computer **Date - 7/08/24** **Topic - Fundamentals of Computer** - **Data:** Raw facts and figures, concepts or instructions that are gathered and entered through a computer. - **Information:** A collection of words, numbers, and symbols in a well-organized manner so that it is...

## Fundamentals of Computer **Date - 7/08/24** **Topic - Fundamentals of Computer** - **Data:** Raw facts and figures, concepts or instructions that are gathered and entered through a computer. - **Information:** A collection of words, numbers, and symbols in a well-organized manner so that it is meaningful to the person using it. **Computer System:** - A computer is an electronic device that stores, manipulates, and retrieves data. - Computers process the information supplied to them and generate data. - A system is a group of several objects with a process. - **Example:** An educational system involves teachers and students (objects). Teachers teach the subject to students, which is the teaching process. - Similarly, a computer system can have objects and processes. The following are the objects of a Computer System. - **User:** A person who uses the computer. - **Hardware:** - The collection of physical elements that comprise a computer system. - Refers to the physical parts or components, such as a monitor, mouse, keyboard, computer data storage (hard drive), system unit, graphic card, sound card, memory, motherboard, chips, etc. - These are physical objects that can be touched. - **Software:** - Refers to the instructions that tell the hardware how to perform a task. - Hardware cannot function without software instructions. - The set of programs that make the hardware perform a set of tasks in a particular order. - Classified into two categories: - **System Software:** Provides the basic, non-task-specific functions of the computer. - **Application Software:** Used by users to accomplish specific tasks. **Block Diagram of Computer:** - **Input:** Used for entering data and programs into the Computer system by the user for processing. - **Secondary Storage:** - The storage unit is used for storing data and instructions before and after processing. - **Memory:** - Classified into two units: - **Primary Memory:** - **RAM (Random Access Memory):** Stores data and instructions when the computer is turned on. - The contents of RAM can be modified. - **Secondary Memory:** - **ROM (Read Only Memory):** Stores data and instructions that remain even when the computer is turned off. - The contents of ROM cannot be modified. - **ALU (Arithmetic Logic Unit):** Performs all calculations and comparisons based on the instructions provided. Functions include addition, subtraction, multiplication, division, and logical operations like greater than, less than, or equal to. - **CU (Control Unit):** Controls all operations like input, processing, and output. - **Output:** Used for storing the results as output produced by the computer after processing. **Cache Memory:** - A high-speed memory that is smaller in size but faster than the main memory (RAM). - The CPU can access it more quickly than the main memory, helping Synchronize with high-speed CPU and improve performance. **Register:** - The smallest and fastest memory in a computer. - Temporarily holds frequently used data, instructions, and memory addresses that are to be used by the CPU. **What is Programming Language?** - Artificial languages designed to communicate instructions to a machine. - Used to create programs that control the behavior of a machine. **Types of Programming Language:** - **Low-level Language:** - **Machine Level Language:** The computer only understands digital numbers in the form of 0 and 1. Instructions are difficult to implement in binary code. Programs are not portable, difficult to maintain, and prone to errors. - **Assembly Language:** A modified version of machine-level language where instructions are given in English-like words (ADD, SUM, MOV, etc.). Easier to write and understand but not understood by the machine, requiring a translator (assembler) to translate into machine-level. Data are stored in computer registers, which vary for different computers, making it not portable. - **High-level Language:** - Machine-independent, meaning portable. Examples include Pascal, COBOL, and FORTRAN. - Understood by the machine through translation. - **Types of Translators:** - **Compiler:** Reads the program as a whole and searches for errors. If error-free, it is converted into an object program. Program size is larger, making compilers preferable. - **Interpreter:** Reads and checks errors one line at a time, converting to object code. It takes more time because it checks statement by statement. **Structure of C Language:** - **Comment Line:** Used to include the purpose of programming. Represented as /*--------*/. - **Pre-processor Directive:** Included at the beginning of the program to tell the compilar (translator) to include information about the standard input/output library. Examples: - `#include <stdio.h>`: Includes the standard input/output library (stdio.h). - `#define PI 3.14`: Declares PI as a symbolic constant. - **Global Variable Declaration:** Declared outside of functions so that they can be accessed by any function in the program. - **Main Function `()`: `int main()`: ** The user-defined function where the program starts, enclosed within curly braces. **Character Set:** - Refers to the alphabets, digits, and special symbols used to represent information. These include valid alphabets, numbers, and special symbols allowed. **Data Type:** - Refers to the extensive system used in C for declaring variables or functions of different types. This determines how much space the variable occupies in storage and what kind of values it can store. **Basic Data Types:** - **char:** One byte, range -128 to 127 (signed) or 0 to 255 (unsigned) - **int:** Two bytes, range -32,768 to 32,767 (signed) or 0 to 65,535 (unsigned) - **short:** One byte, range -128 to 127 (signed) or 0 to 255 (unsigned) - **long:** Four bytes, range -2,147,483,648 to 2,147,483,647 (signed) or 0 to 4,294,967,295 (unsigned) - **float:** Four bytes, range -3.4E+38 to 3.4E+38 - **double:** Eight bytes, range -1.7E+308 to 1.7E+308 - **long double:** Ten bytes, range -3.4E+4932 to 3.4E+4932 **Constant:** - A value that cannot be changed during program execution. - Can be divided into two major categories: - **Primary Constants:** - **Integer Constants:** Whole numbers without decimal points. - **Decimal Constants:** Base 10, 0-9 - **Octal Constants:** Base 8, 0-7 - **Hexadecimal Constants:** Base 16, 0-9, A-F - **Real Constants:** Numbers with decimal points, referred to as floating-point constants. - **Character Constants:** Single characters enclosed in single quotes, including digits, special symbols, and spaces. - **Secondary Constants:** - **Arrays:** A collection of variables of the same data type. - **Pointers:** Variables that store memory addresses. - **Structures:** User-defined data types that combine variables of different data types. - **Unions:** Allow variables of different data types to share the same memory location. - **Enums:** A set of named integer constants. **Numeric Constants:** - Consist of digits and can be positive or negative. - By default, they are positive. - Classified as integer constants and real constants. - **Integer Constants:** Whole numbers without decimal points. - **Real Constants:** Numbers with decimal points. **Character Constants:** - Represented as a single character within single quotes. - Can be a digit, a special symbol, or a space. - Every character constant has a unique integer value in the machine's character code, usually ASCII (American Standard Code for Information Interchange). **Arithmetic Operators:** - Used for numeric calculations. - Can be either unary (operating on one operand) or binary (operating on two operands). **Unary Operators:** - **+ (Unary Plus):** Returns the operand itself. - **- (Unary Minus):** Returns the negative of the operand. - **++ (Increment):** Increases the value of the operand by 1, either before (prefix) or after (postfix) evaluating the operand. - **-- (Decrement):** Decreases the value of the operand by 1, either before (prefix) or after (postfix) evaluating the operand. - **! (Logical Not):** Returns the opposite truth value of the operand. **Binary Operators:** - **+ (Addition):** Adds the operands. - **- (Subtraction):** Subtracts the second operand from the first. - **\* (Multiplication):** Multiplies the operands. - **\ (Division):** Divides the first operand by the second. - **% (Modulus):** Returns the remainder of the integer division of the first operand by the second. **Assignment Operators:** - Assign a value to a variable. - The most common assignment operator is the equals sign (=), which assigns the value on the right side to the variable on the left side. - Other assignment operators: - **+= (Add and Assign):** Adds the value on the right side to the variable on the left side and assigns the result to the variable on the left side. - **-= (Subtract and Assign):** Subtracts the value on the right side from the variable on the left side and assigns the result to the variable on the left side. - **\*= (Multiply and Assign):** Multiplies the value on the right side by the variable on the left side and assigns the result to the variable on the left side. - **/= (Divide and Assign):** Divides the variable on the left side by the value on the right side and assigns the result to the variable on the left side. - **%= (Modulus and Assign):** Calculates the modulus of the variable on the left side by the value on the right side and assigns the result to the variable on the left side. **Relational Operators:** - Used to compare the values of two expressions. - The result is either true or false. - **< (Less than):** Returns true if the left operand is less than the right operand, false otherwise. - **> (Greater than):** Returns true if the left operand is greater than the right operand, false otherwise. - **<= (Less than or equal to):** Returns true if the left operand is less than or equal to the right operand, false otherwise. - **>= (Greater than or equal to):** Returns true if the left operand is greater than or equal to the right operand, false otherwise. - **== (Equal to):** Returns true if the operands are equal, false otherwise. - **!= (Not equal to):** Returns true if the operands are not equal, false otherwise. **Logical Operators:** - Work with boolean operands (true or false) and return true or false results based on the truth values of the operands. - **! (Logical NOT):** Negates the operand, returning true if the operand is false, and false if the operand is true. - **&& (Logical AND):** Returns true if both operands are true, false otherwise. - **|| (Logical OR):** Returns true if at least one operand is true, false if both operands are false. **Bitwise Operators:** - Work on the individual bits of the operand. - **~ (Bitwise NOT):** Inverts the bits of the operand, changing all 0s to 1s and all 1s to 0s. - **& (Bitwise AND):** Performs a bit-by-bit AND operation on the operands. - **| (Bitwise OR):** Performs a bit-by-bit OR operation on the operands. - **^ (Bitwise XOR):** Performs a bit-by-bit XOR operation on the operands. - **<< (Left Shift):** Shifts the bits of the operand to the left, filling the vacated positions with 0s. - **>> (Right Shift):** Shifts the bits of the operand to the right, filling the vacated positions with 0s or 1s, depending on the sign of the operand. **Conditional Operator:** - A ternary operator, meaning it takes three operands. - Used to shorten an IF-ELSE statement. - **?: (Conditional Operator):** The conditional statement is evaluated: `conditional_expression ? expression1 : expression2`. If the `conditional_expression` is true, `expression1` is evaluated, otherwise `expression2` is evaluated. **`sizeof()` Operator:** - Returns the size of a variable, constant, or data type in bytes. **Control Statements:** - Determine the order in which statements are executed. - Control flow can be altered using control statements like if-else, switch, while, do-while, for, break, and continue. **Loops:** - A block of code that is executed repeatedly until a certain condition is met. **`while` Loop:** - Executes a block of code as long as a specified condition is true. **`do-while` Loop:** - Executes a block of code at least once, and then continues to execute as long as a specified condition is true. **`for` Loop:** - Iterates a block of code a specified number of times. **`break` Statement:** - Exits a loop or switch statement prematurely. **`continue` Statement:** - Skips the current iteration of a loop and continues to the next iteration. **`if-else` Statement:** - Executes a block of code only if a specified condition is true, otherwise executes another block of code. **`switch` Statement:** - Executes a block of code based on the value of a variable. **Understanding the difference between `break` and `continue`:** - `break`: Exits the loop entirely, terminating the loop execution. - `continue`: Skips the current iteration of the loop and continues to the next iteration, without exiting the loop. This document describes the fundamentals of computers. This is a basic introduction to the concepts of computer science, but it is not exhaustive. There is much more to learn about computers and their applications.

Use Quizgecko on...
Browser
Browser