Tuesday, July 21, 2015

Circular Queue Operation In Data Structure Using C Programming

Hello guys,
Here i am gonna show how to perform Circular Queue Operation in Data Structure using C programming.




#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#define max 3
struct student {
    int roll[max];
    int rear;
    int front;
}s;
int isEmpty() {
    if(s.front == s.rear)
        return 1;
    else
        return 0;
}
int isFull() {
    if(s.front == (s.rear+1)%max)
        return 1;
    else
        return 0;
}
int display() {
    int i;
    if(isEmpty() == 1)
        printf("The Queue is Empty\n");
    else {
    for(i=s.front+1;i<=s.rear;i++)
        printf("%d\t",s.roll[i]);
    }
}
int enqueue(int num) {
        s.rear = (s.rear+1)%max;
        s.roll[s.rear] = num;
        return 1;
}
int dequeue() {
    s.front = (s.front+1)%max;
    return 1;
}
int loop() {
    int opt;
    printf("\nDo you want to continue to main menu?? 1.yes 2.no \t");
    scanf("%d",&opt);
    system("cls");
    return opt;
}
void main() {
    int opt,r;
    s.front = 0;
    s.rear = 0;
    do {
    printf("\t\t\t\t*****Queue*****\n");
    printf("1. Isempty \n2. Isfull\n3. Enqueue\n4. Dequeue\n5. Display\t");
    scanf("%d",&opt);
    switch(opt) {
        case 1 :
            if(isEmpty() == 1)
                printf("The Queue is empty");
            else
                printf("The is not Empty");
            break;
        case 2 :
            if(isFull() == 1)
                printf("The Queue is full");
            else
                printf("The is not full");
            break;
        case 3 :
            if(isFull() == 1)
                printf("Cannot add new item, queue is full!!");
            else {

                printf("\nEnter the number you want to add in queue \t");
                scanf("%d",&r);
                if(enqueue(r) == 1) {
                    printf("Succesfully number aded in queue !! \n");
                    }
            }
            break;
        case 4 :
            if(isEmpty() == 1)
                printf("Empty Queue");
            else {
                if(dequeue() == 1)
                    printf("Successfullly deleted item :)");
            }
            break;
        case 5 :
            display();
            break;
        default :
            printf("Invalid input");
            break;
    }
} while(loop() == 1);
}






Open C Compiler(any) and paste the above code, enjoy....

Monday, July 20, 2015

Add two 16 bit number using Assembly Level Language

Here, am gonna illustrate you how to add two 16 bit numbers from Assembly level Language.
Here we go,


The full code is as,
LDA 2050
MOV B,A
LDA 2051
ADD B
JNC label
INR C
label: STA 2053
MOV A,C
STA 2054
HLT


Here,
LDA 2050
        It means, load accumulator with data of 2050 memory address.
Now, it becomes A = data of 2050 
MOV B,A
        It means, Move data of Register A to register B.
LDA 2051
        Same as first one.
ADD B
       It means, add  the content of  register B to A and put output on A.
JNC label
       It means, if carry occurs no jumping to label, else jump to label.
INR C
         Increase C register by 1.
label: STA 2053
         Store the content of accumulator in 2053 address memory

Similarly, the steps are followed..

Finally, we get Our result at   2053 with carry at 2054. HLT terminate our program.

What is Microprocessor? Explain it's History.

What is Microprocessor? Explain it's History.
Microprocessor is a program controlled device which fetches the instruction from memory, decodes it and executes the instructions. It is a multipurpose, programmable, clock driven register based electronic device, that reads binary instructions from storage, accept binary data and provide result as output.

There is great contribution of INTEL corporation for the development of microprocessors. It developed various series of microprocessors as :-
    • Intel 4004 :- It is introduced in 1971. It is 4 bit, consist of 16 pins with  clock signal of 7050 Hz
    • Intel 8008 :- It is introduced  in 1972 and is 8 bit. It consists of 40 pins.
    • Intel 8080 :- It is introduced in 1973 and id of 8 bit. It is 10 times faster than 8008.
    • Intel 8085 :- It was firstly released on 1976. It  was updated version of 8080 and it is also  of 8 bit. It consist of addressing capacity of 64 KB. It have 40 pins.
    • Intel 8086 :-  Introduced in 1978 and is of 6 bit. Addressing capacity is of 1 MB. It also have 40 pins. It consists of 5-0 MHz clock signal.
    • Intel 8088 :- Introduced in 1980. It is of both 8/16  bit. Addressing memory  is of 1 MB and have 5.8 MHz of clock signal.
    • Intel 80286 :- Introduced in 1992 and is of 16 bit.  Addressing memory capability is up to 16MB. It have 68 pins. 6-12.8 MHz clock signal.
    • Intel 80386 :- It was firstly developed on 1985 and is of 32 bit. It have capability of 4 GB addressing. It consists of 132 pins with 26-100MH clock signal.
    • Intel 80486 :- It was developed on 1989 and is of 32 bit with 4 GB addressing capacity memory. Consists 168 pins with 26-100 MHz clock signal.
    • Pentium processors (80586) :- It is introduced in 1993 with 32 bit and 4 GB memory addressing capability. It consists of with 100 and 150 MHz.
 Pentium pro, Pentium II, Pentium III, was developed each with 32 bit word length having 150-1000 MHz clock signal.