

























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


























A computer is an electronic machine that takes input from the user, processes the given input and generates output in the form of useful information A computer accepts input in different forms such as data, programs and user reply. Programs refer to the set of instructions that can be executed by the computer in a sequential or non-sequential manner. Characteristics of Modern Computer: Speed: Computer is a fast electronic device that can solve large and complex problems in few seconds. The speed of a computer depends upon its hardware configuration. Storage capacity : A computer can store huge amount of data in many different formats. Computer storage is divided into 2 categories: Main memory and Secondary storage. Accuracy : A computer carries out calculations with great accuracy. The accuracy achieved by a computer depends upon its hardware configuration and the specified instructions. Reliability : A computer produces results with no error. Most of the computer-generated errors are in actuality human errors that are instigated by the user itself. Therefore, computers are regarded as quite trustworthy machines. Versatility : Computers are versatile machines. They can perform varied tasks and can be used for many different purposes. Diligence: Computers can perform repetitive calculations any number of times with the same level of accuracy. COMPONENTS OF COMPUTER A computer is a system made of two major components: Hardware and Software. The computer hardware is the physical equipment. Computer software is the collection of programs that allows hardware to do its job. Hardware component of the computer system consists of five components:
Central Processing Unit (CPU) It is called as the brain of the computer. It is the processor of the computer that is responsible for controlling and executing instructions such as arithmetic calculations, comparisons among the data, and movement of data inside the system. Three components of CPU: Arithmetic and Logic Unit, Control Unit, Registers. Arithmetic and Logic Unit (ALU) ALU is a part of the CPU that performs arithmetic and logical operations on the data. It performs arithmetic operations such as addition, subtraction, multiplication, division etc. It performs logical operations such as greater than, less than, equal to, not equal to, left shift, right shift etc. ALU takes input as an instruction that contains Opcode, Operands & Format code. The output of ALU contains the result of the operation & the status of the result, whether it is final or not. ALU stores the output in the CPU register. Control Unit (CU) Control Unit controls the flow of data and information. It maintains the sequence of operations being performed by the CPU. Control Unit guides the ALU about the operations that are to be performed. Control unit suggests the I/O devices to which the data is to be communicated. It uses a program counter register for retrieving the next instruction that is to be executed. Registers CPU Registers are high-speed memory locations used for holding instructions, data and intermediate results that are currently being processed. A processor can have different types of registers to hold different types of information. Program Counter (PC) to keep track of the next instruction to be executed. Accumulator (ACC) for storing the results produced by arithmetic and logic units. Memory Data Register (MDR) for storing operands and data. Memory Address Register (MAR) to hold the address of the next location in the memory to be accessed. Note: Buses are electrical pathways that transfer data and instructions among different parts of the computer. (i.e) transfers data among the processor to main memory devices and input/output devices connected to the computer. Memory Unit The memory unit of a computer is used to store data, instructions. The memory units of a computer are classified as primary memory and secondary memory. Main memory or Primary storage It is a place where the programs and data are stored temporarily during processing. The data in primary storage are erased when we turn off a personal computer or when we log off from a time-sharing system. Examples: Random Access Memory (RAM), Read-Only Memory (ROM).
The purpose of an operating system is to provide an environment in which a user can execute programs in a convenient and efficient manner. The operating system manages the resources such as CPU time, memory space, file-storage space, I/O devices and so on. An operating system is a control program that manages the execution of user programs to prevent errors and improper use of the computer. Compilers The process of converting high-level language code into machine language code is known as compilation. A compiler is a software program that transforms high-level language source code into a low level object code (binary code) in machine language. Machine language code is understood by the processor. High level language code understood by user. COMPUTER LANGUAGES Computer Languages are categorized into 3 levels:
Compilers are used to convert the high level language code to machine code. That means it converts alphabets and digits and other special characters to 0's and 1's. Some programming languages uses interpreter to convert to machine code. Let the instruction: C=A+B A, B, C are memory locations and the values of A and B are added and stored in C. Programmers don’t need to manage memory addresses, CPU registers, or binary code directly. Debugging is easy in high level languages. CREATING AND RUNNING PROGRAMS It is the job of a programmer to write and run the program. This process involves four steps.
Hence, there should be continuous interaction between the software development team and the end users. Proper analysis of user requirements is quite essential for developing the software within a given timeframe. It is used to control the software development cost. It lead to faster and accurate development of a software. Feasibility Analysis Here, we will check whether the proposed software project is practical to implement or not. In order to determine the feasibility of software development, the existing system of the user is analyzed properly. Here we can understand requirements from user, collects background information, analyzing technical , economical, time schedule feasibility, and identify any risks or limitations in of the software project. The analysis done in this step is documented as a report called feasibility report. Creating the Design This step involves developing a logical model or basic structure of the new software. This step involves documenting the various specifications related to database and data structure design using UML diagrams. The software design should be flexible and extensible. Software should be modular in nature, so we can develop multiple module at the same time. Software should run correctly in the existing system with an older version or with other software. Software design must ensure secure and fault tolerant. Developing the Code According to the design specifications, the code for the different modules are developed. The code can be written using programming languages such as C, C++ or Java. The code must follow Proper naming conventions, proper indentation, and write proper comments,. The code must be easily understood and logically correct. The programmers use debugging tools to find errors in the code. The programmers use compilers, interpreters to convert the code into machine language for its execution. Testing the Software Testing is used to detect any errors in the new software and rectify those errors. verifi cation and validation activities will be performed during testing. Verifi cation is the process of checking the software based on some predefined specifi cations. Validation involves testing the product to ascertain whether it meets the user’s requirements so that we willg get correct output.
We use various testing such as unit testing, integration testing, black box testing,white box testing etc. Deploying the Software In this step, we deliver the software to the end user. That means software is installed in its target environment. Software documentation is handed over to the users. Some initial data are entered in the software to make it operational. The users are also given training on the software’s interface and its other functions. Maintaining the Software It ensures that the software continues to run smoothly after its deployment. During this phase, developers fix bugs reported by users, update the software to enhance security and improve performance, and add new features when required. The outcome of this phase is an updated and improved version of the software that meets evolving user needs and technological requirements. COMPUTING ENVIRONMENTS There are several computing environment are built for different computing purposes:
A Flow chart is a pictorial representation of an Algorithm. The diagrammatic representation to solve the given problem is called Flow chart. The flow of information is represented inside the flowchart in a step-by-step form. Flowchart uses different symbols for depicting different activities. Name Representation Description Start and End (^) Starting and Ending of a process is represented by an oval or a rounded rectangle. Every flow chart must have start and end symbols. Input / Output It is represented by a parallelogram. All Input and output statements of process are written inside parallelogram. Action / process / calculations It is represented by a rectangle. All the statements related to calculations, actions, logics are written inside rectangle. Decision/ condition All the conditional statements are written inside a rhombus. Ex: if a>0. The result is either true or false. Each of these values takes the flow of the program to a different direction. Arrow Arrow represents the flow of process and the sequence of steps in a flowchart. Connector It is represented by a circle in a flowchart. It represents the continuation of the flow of steps when a flowchart continues to the next page. A character such as an alphabet (a-z or A-Z) can be placed in the circle at the position where the flow is broken and the same character is also placed in the circle at the position from where the flowchart continues. Rules for Designing a Flowchart It must begin with a “Start” and end with a “Stop” symbol. The standard process flow should be either from top to bottom or from left to right. The instructions specified in the flowchart must be simple and concise. The arrows must be aligned properly so as to clearly depict the flow of program control. A process or action flowchart symbol must have only one input arrow and one output arrow. Use of connectors should be generally avoided as they make the program more complex. Advantages of Flowcharts Visual representations gives better understanding of problem statement. It helps to understand the flow of program control in an easy way. It is easy to develop program code using flow charts. It helps in avoiding semantic errors. The use of flowcharts works well for small program design.
Disadvantages of Flowcharts For a large program, the flow chart might become very complex and confusing. Modification of a flowchart is difficult and requires lot of rework. It takes a lot of time to create a flowchart. Excessive use of connectors in a flowchart may confuse the programmers. PSUDO CODE Pseudo code only focuses on the logic of the program. Pseudo code does not have any specific syntax, we can write it in general English language. Pseudo code helps the programmer understand the basic logic of the program. Once we write a pseudo code, a programmer can select any programming language to write the source code of program. Rules for writing Pseudo code Instruction or operation code in a pseudo code statement must be kept all capitalized; Example: READ (specifying input operation), PRINT (specifying print command) etc. The ending of looping and decision-making constructs must be labelled appropriately with corresponding “END” keywords. The pseudo code instructions must be properly indented just like the statements are indented in a computer program. Convoluted programming instructions must be avoided by writing simple and clear instructions. Advantages of Pseudo code It is easy to understand as it uses English phrases for writing program instructions. Developing program code using pseudo code is also easier in comparison to flowcharts. Modifying the pseudo code instructions are easier. The use of pseudo code works well for large program design. Disadvantages of Pseudo code There is no standard format for developing a pseudo code. Therefore, it may become a challenge to use the same pseudo code by different programmers. Since pseudo code does not use any kind of pictorial representations for program elements, sometimes, it may become difficult to understand the program logic. Pseudo codes are at a disadvantage in comparison to flowcharts when it comes to understanding the flow of program control. Write an algorithm to find the average of marks obtained by a student in three subjects.
Draw a flowchart to find out whether a given number is prime or not.
There are four types of Number systems are used by computers:
There are total of 2 symbols used in Binary system 0 &1. It is used by computers to represent data. Each digit’s position represents a power of 2. Octal system The Octal system is base 8, represented as (X) 8. Total of 8 symbols (0-7) are used in octal system 0, 1, 2, 3, 4, 5, 6, 7. Each digit’s position represents a power of 8. Hexa Decimal system
Total of 16symbols used 0-9 and A-F. (i.e.) 0, 1, 2, 3, 4, 5, 6, 7,8,9,A,B,C,D,E,F. Here A-10, B-11, C-12, D-13, E-14, F-15. Each digit’s position represents a power of 16. NUMBER SYSTEM CONVERSION The following conversions can be done:
Note: If the left most group does not have 3 bits then we prefix 0 ’s to the left over bits in that group so that it will become a group of 3. Example_2: Convert the binary number (1101101) 2 to Octal number. Group 3 bits from the right side: (1) (101)(101). The left most group has only one bit, hence we need to prefix 2 bits of 0 ’s, to make it a group of 3-bits. Therefore, (001) (101) (101) hence, 001 1, 101 5, 101 5 Hence (1101101) 2 = (155) 8 Binary to Hexa-Decimal conversion To convert a binary number to Hexa-Decimal number we need to group of 4 bits from the right side. The Hexa-Decimal values are ranging from 0-9 and A-F. Hence, a group of 4 bits ranges from 0000 to 1111 represents 0-F as shown below. 0 - 0000 4 - 0100 8- 1000 C- 1100 1 - 0001 5 - 0101 9- 1001 D- 1101 2 - 0010 6 - 0110 A- 1010 E- 1110 3 - 0011 7 - 0111 B- 1011 F- 1111 Example_1: 10110001 We can group 4 bits from right, hence we divide them into (1011) (0001). 1011 B and 0001 1. Hence , (10110001) 2 = (B1) 16 Note: If the left most group does not have 4 bits then we prefix 0 ’s to the left over bits in that group so that it will become a group of 4. Example_2: Convert the binary number (1101101) 2 to Hexa-Decimal number. Group 4 bits from the right side: (110)(1101). The left most group has only 3 bits, hence we need to prefix 1 bit of 0 ’s, to make it a group of 4-bits. Therefore, (0110)(1101) Hence 0110 6, 1101 D Hence (1101101) 2 = (6D) 16 Octal to Decimal Conversion To convert from octal to decimal system, we need to multiply each digit with powers of 8. Example: Let the octal number be (354) 8. =(38^2 ) + (58^1 ) + (48^0 ) =(364) + (540) + (41) =192 + 200 + 4 =396. Answer: (354) 8 = (396) 10 Octal to Binary conversion To convert from octal to binary, we need to write the 3-bit binary value for each octal digit. Example: Convert (354) 8 to binary value. (3) 8 – 011 (5) 8 101 (4) 8 100 Answer: (354) 8 = (011101100) 2
Hexa Decimal to Decimal conversion To convert from octal to decimal system, we need to multiply each digit with powers of 16. Example: Let the hexa decimal value be (45F) (^16) =(416^2 ) + (516^1 ) + (F16^0 ) =(4256) + (516) + (151) =1024 + 80 + 15 =1119. Answer: (45F) 16 =(1119) 10. Hexa Decimal to Binary conversion To convert from octal to binary, we need to write the 3-bit binary value for each octal digit. Example: Convert (35F) 16 to binary value. (3) 16 0011 (5) 16 0101 (F) 16 1111 Hence (35F) 16 = (001101011111) 2 Octal to Hexa Decimal conversion We need to follow two steps to convert from octal to hexa decimal:
main() section: Every C program must have one main() function. main() contains two parts, variable declaration part and executable part. Declaration part declares all the variables used in the executable part. Opening and the closing braces { } are used to define the scope of main( ). The program execution begins at the opening brace and ends at the closing brace. All statements in declaration and executable parts end with a semicolon (;). Subprogram section contains all the user-defined functions that are called in the main(). Note: main( ) section is mandatory and all remaining sections are optional. CHARACTER SET The characters in C are grouped into the four categories:
Constants in C refer to fixed values that do not change during the execution of a program.