Saturday, 15 October 2016

Program to implement Simple Queue using Array in C

/*
         Program to implement a Simple Queue using Array.
         Created By: Pirate
*/

#include<stdio.h>
int queue[200];
int front = -1;
int rear = -1;
int size = 0;
void enqueue();
void dequeue();
void traverse();
void main(){
    int ch = 1;
    printf("*** Single Queue Using Array ***");
    do{
        printf("\nEnter the size of Queue : ");
        scanf("%d", &size);
        if(size < 1){
            printf("\nInvalid Queue size. \n Continue Y : 1/N : 0 - ");
            scanf("%d",&ch);
            if(ch == 0)
                exit(0);
        }
    }while(size < 1 && ch == 1);
    do{
        printf("\n1 : Insert\n2 : Delete\n3 : Traverse\n4 : Exit\n");
        scanf("%d",&ch);
        switch(ch){
            case 1:
                enqueue();
                break;
            case 2:
                dequeue();
                break;
            case 3:
                traverse();
                break;
            case 4:
                exit(0);
                break;
            default:
                printf("\n Invalid input. \n");

        }
    }while(1);
}
void enqueue(){
    if(rear == size - 1){
        printf("\nQueue is full");
        return;
    }
    if( rear == -1){
        rear = 0;
        front = 0;
    }
    else
        rear = rear + 1;
    printf("\nEnter the value to input : ");
    scanf("%d", &queue[rear]);
    printf("\n Success.");
}
void dequeue(){
    if(front == -1){
        printf("\nQueue is Empty.");
        return;
    }
    if(front == size - 1){
        front = -1;
        rear = -1;
    }
    else if(front == rear){
        front = -1;
        rear = -1;
    }
    else
        front = front + 1;
    printf("\n Success.");
    return;
}
void traverse(){
    int i;
    if(front == -1){
        printf("\nQueue is Empty.");
        return;
    }
    printf("\nQueue : \n");
    for(i=rear;i>=front;i--){
            printf("%d\t",queue[i]);
    }
    return;

}


Output :


Program to implement Stack using array in C language

/*
         Program to implement a Stack using Array.
         Created By: Pirate
*/

#include<stdio.h>
int stack[200];
int push(int top,int size);
int pop(int top);
int traverse(int top);
void main(){
    int size,top=-1;
    int ch=1;
    printf("*** Stack Using Array ***");
    do{
        printf("\nEnter the size of Stack : ");
        scanf("%d", &size);
        if(size < 1){
            printf("\nInvalid Stack size. \n Continue Y : 1/N : 0 - ");
            scanf("%d",&ch);
            if(ch == 0)
                exit(0);
        }
    }while(size < 1 && ch == 1);
    do{
        printf("\n1 : Insert\n2 : Delete\n3 : Traverse\n4 : Exit\n");
        scanf("%d",&ch);
        switch(ch){
            case 1:
                top = push(top,size);
                break;
            case 2:
                top = pop(top);
                break;
            case 3:
                top = traverse(top);
                break;
            case 4:
                exit(0);
                break;
            default:
                printf("\n Invalid input. \n");

        }
    }while(1);
}
int push(int top,int size){
    if(top == size - 1){
        printf("\nStack is full");
        return top;
    }
    top = top + 1;
    printf("\nEnter the value to input : ");
    scanf("%d", &stack[top]);
    printf("\n Success.");
    return top;
}
int pop(int top){
    if(top == -1){
        printf("\nStack is Empty.");
        return top;
    }
    top = top - 1;
    printf("\n Success.");
    return top;
}
int traverse(int top){
    int i;
    if(top == -1){
        printf("\nStack is Empty.");
        return top;
    }
    printf("\nStack : \n");
    for(i=top;i>=0;i++){
            printf("%d\n",stack[i]);
    }
    return top;
}

Output : 





Wednesday, 13 July 2016

Download Pokemon Go Free

Hi Friends,
        After a long time. How are you all? Good ha.
        You have heard  about Pokemon Go but din't find on Play Store. Don't worry. You can download Pokemon Go here.




Thank you.
Comment and Share. :)