Posts

Binary Search

Program on Binary Search #include<iostream.h> #include<conio.h> void main() {       clrscr(); int n, i, a[30], x, first, last, middle; cout<<"How many elements would you like to enter?:"; cin>>n; for (i=0; i<n; i++) { cout<<"Enter number "<<(i+1)<<": "; cin>>a[i]; } cout<<"Enter the number that you want to search:"; cin>>x; first = 0; last = n-1; middle = (first+last)/2; while (first <= last) {    if(a[middle] < x)    { first = middle + 1;    }    else if(a[middle] == x)    { cout<<x<<" is found in the array at the location "<<middle+1<<"\n"; break;    }    else { last = middle - 1;    }    middle = (first + last)/2; } if(first > last) {    cout<<x<<" is not found in the ...

Linear Search

Program on Linear Search #include<iostream.h> #include<conio.h> void main() { int a[30],i,n,pos=0,x,flag=0; clrscr(); cout<<"Enter the number of elements in array: "; cin>>n; cout<<"\nEnter the elements in array: "; for (i=0;i<n;i++) { cin>>a[i]; } cout<<"\nEnter the element to be searched: "; cin>>x; for(i=0;i<n;i++) { if(a[i]==x) { pos=i; flag=1; break; } } if(flag==0) { cout<<"\nUnsuccessful Search"; } else { cout<<"\nThe element is found at position "<<pos+1; } getch(); }

CISC / RISC / EPIC

Classification of Microprocessors 1.     CISC Processors: CISC is known as Complex Instruction Set Computer . The CISC approach attempts to minimize the number of instructions per program, sacrificing the number of cycles per instruction. Computers based on the CISC architecture are designed to decrease the memory cost . The number of instructions per program can be reduced by embedding the number of operations in a single instruction, thereby making the instructions more complex. For example, MUL(Multiply) . It performs operations such as load from memory, an arithmetic operation and a memory store all in single instruction. Example: IBM 370/168, Intel 80486 etc. Advantages: a.      Microprogramming is as easy as assembly language to implement and much less expensive than hardwiring a control circuit. b.      Fewer instructions are needed to implement a particular computing task, which led to lower memory...

Types of Memory

Types of Memory The computer memories can be divided into following categories: ·         Primary Memory ·         Secondary memory ·         Cache Memory 1.     Primary Memory: Primary memory or main memory is used for storing program and data during the execution of the program. It is directly accessible to CPU. The main memory is divided into many storage locations , each of which can store data or instructions. Each memory location is of the same size and has an address. With the help of the address, the computer can find any data easily without having to search the entire memory. Broadly primary memory can be of two types – RAM (Random Access Memory) and ROM (Read only memory). a.      Random Access Memory (RAM) RAM is also known as volatile memory is a computer memory that requires power to maintain the stored...

Microprocessor

Image
Microprocessor A microprocessor is an electronic circuit that is fabricated on a single chip. It is the heart of all the computers. The instructions given in a program are interpreted and carried out by the processing unit of computer. So, we can say that a microprocessor is a multipurpose, programmable device that reads binary instructions from a storage device called memory, accepts binary data from input units and processes data according to these instructions and provide results as output. A processor is also known as CPU which is also called as brain of the computer. The main components of CPU are: 1.      Control Unit 2.      Arithmetic Logic Unit 3.      Registers 1.    Control Unit(CU) -> A control unit is that part of computer, which makes the ALU and memory work in synchronization with the data. It is responsible for carrying out all the instructions stored in the progr...