<file_sep>#include<stdio.h>
int main(){
    int i,n;
    int large,secondLarge;
    int arr[20];

    printf("Enter Size of Array :\n");
    scanf("%d",&n);

    printf("Elements are : \n");
    for (i = 0; i < n; i++){
        scanf("%d",&arr[i]);
    }
    for(i=0;i<n;i++){
        printf("Elements Are Arra[%d] = %d\n",i,arr[i]);
    }

    large = arr[0];
    for(i=0;i<n;i++){
        if(large < arr[i]){
            large = arr[i];
        }
    }
    secondLarge = arr[1];
    for(i=0;i<n;i++){
        if(arr[i] != large){
            if (secondLarge < arr[i]){
                secondLarge = arr[i];
            }

            
        }
    }
    

    printf("Large Number is : %d\n",large);
    printf("Second Large Number is : %d\n",secondLarge);
    return 0;
    
}<file_sep>#include <stdio.h>
#include<stdlib.h>
struct node{
        int data;
        struct node* link;
};
struct node* root = NULL;
int len;

void append();
void insert();
void display();
void delete();
int length();
void main(){
    int ch;
    while (1)
    {
        printf("Single linked list operation:\n");
        printf("1.Append  :\n");
        printf("2.Insert :\n");
        printf("3.length :\n");
        printf("4.Display :\n");
        printf("5.Delete :\n");
        printf("6.quite :\n");

        printf("Enter your Choice :\n");
        scanf("%d",&ch);

        switch(ch){
            case 1 : append();
                    break;
            case 2 : insert();
                    break;
            case 3 : len =length();
                        printf("Length is : %d\n\n",len);
                    break;
            case 4 : display();
                    break;
            case 5 : delete();
                    break;
            case 6 : exit(1);
                
            default : printf("invlid Choice :");
        }
    }
    
}
void append(){
    struct node* temp;
    temp = (struct node*)malloc(sizeof(struct node));

    printf("Enter node data :");
    scanf("%d",&temp->data);
    temp->link = NULL;

    if (root == NULL){
        
        root = temp;
    }else{
        struct node* p;
        p = root;

        while (p->link !=NULL){
            p = p->link;
        }
        p->link = temp;
        
    }
    
}
int length(){
    int count = 0;
    struct node* temp;
    temp = root;

    while (temp != NULL){
        count++;
        temp = temp->link;
    }
    return count;
    
}
void insert(){
    struct node* temp,*p;
    int loc;
    int i=1;
    printf("Enter location :");
    scanf("%d",&loc);

    if(loc > length()){
        printf("invalid length!!\n");
        printf("Available length is : %d",len);
    }
    else{
        p =root;
         while(i < loc){
             p = p->link;
             i++;
        }
        temp = (struct node*)malloc(sizeof(struct node));
        printf("Enter the node :");
        scanf("%d",&temp->data);
        temp->link = p->link;
        p->link = temp;
    }
    
}
void delete(){
    struct node* temp;

    int loc = 0;
    printf("Enter the Location :\n");
    scanf("%d",&loc);

    if (loc > length()){
        printf("Invalid location !");
    }
    else if (loc == 1){
        temp = root;
        root = temp->link;
        temp->link = NULL;
        free(temp);
    }
    else{
        struct node* p = root;
        struct node* q;
        int i=1;
        while (i < loc-1){
            p = p->link;
            i++;
        }
        q = p->link;
        p->link = q->link;
        q->link = NULL;
        free(q);
    }
    
}
void display(){
    struct node* temp;
    temp = root;
    if (temp == NULL){
        printf("Empty\n");
    }
    else{
        while(temp != NULL){
            printf("%d-->",temp->data);
            temp = temp->link;
        }
        printf("\n\n");
    }
    
}
<file_sep>#include <stdio.h>
#include <stdlib.h>
#define CAPACITY 5 // macro prefrocer
int stack[CAPACITY],top= -1;

void push(int);
int pop(void);
int peek(void);
int traverse(void);
int isEmpty(void);
int isFull(void);

void main(){
while(1){
    int ch;
    int item;
    printf("1.PUSH\n");
    printf("2.POP\n");
    printf("3.PEEK\n");
    printf("4.TRAVERSE\n");
    printf("5.Exit\n");

    printf("Enter Your Choice :");
    scanf("%d",&ch);

    switch(ch){
        case 1: printf("Enter Element :");
                scanf("%d",&item);
                push(item);
                break;

        case 2: item = pop();
                if(item == 0){
                    printf("Stack is UnderFlow\n");
                }else{
                    printf("Poped Item is : %d\n",item);
                }
                break;
        case 3: peek();
                break;
        case 4: traverse();
                break; 
        case 5: exit(0);
                break;
        default: printf("Invalid Input!!!!\n");  
    }

}
}
void push(int item){
    if (isFull()){
        printf("Stack is OverFlow\n");
    }
    else{
        top++;
        stack[top] = item;
        printf("Push Element %d\n",item);
    }
    
}
int isFull(){
    if (top == CAPACITY - 1 ){
        return 1;
    }
    else{
        return 0;
    }
    
}
int pop(){
    if (isEmpty()){
        return 0;
    }
    else{
        return stack[top--];
    }
    
}
int isEmpty(){
    if (top == -1)
    {
       return 1;
    }else
    {
        return 0;
    }
}
int peek(){
    if(isEmpty()){
        printf("Stack UnderFlow\n");
    }else{
        printf("Peek is %d\n",stack[top]);
    }
}
int traverse(){
    if(isEmpty()){
        printf("Stack  is overFlow\n");
    }else{
        int i;
        for(i=0;i<=top;i++){
            printf("Elements are %d\n",stack[i]);
        }
    }
}<file_sep>#include<stdio.h>
int main(){
	int i,n;
	int arr[20];
	int total = 0;
	float avg = 0;
	
	printf("Enter size of Array : ");
	scanf("%d",&n);

	printf("Enter Elements :\n");

	for(i=0;i<n;i++){
		printf("ARRAY[%d] = ",i);
		scanf("%d",&arr[i]);
	}

	printf("Elements are :\n");
	for(i=0;i<n;i++){
		printf("Array[%d] = %d\n",i,arr[i]);
	}
	 
	for(i=0;i<n;i++){
		total = total + arr[i];
	}
	avg = (float)total/n;
	printf("Total is %d\n",total);
	printf("Average is %f\n",avg); 
	return 0;
}
<file_sep>#include <stdio.h>
int main(){
    int i,n,loc;
    int arr[20];

    printf("Enter Size of Array :");
    scanf("%d",&n);

    printf("Enter the Elements :\n");
    for(i=0;i<n;i++){
        printf("Array[%d] =",i);
        scanf("%d",&arr[i]);
    }
    printf("Enter location to Delete :");
    scanf("%d",&loc);

    for(i=loc;i<n-1;i++){
        arr[i] = arr[i+1];
    }
    for(i=0;i<n-1;i++){
        printf("Array[%d] = %d\n",i,arr[i]);
    }

    return 0;
}<file_sep>#include<stdio.h>
int stack[10];
int top = -1;
int arr[10];
void push(int);
int pop();
void main(){
    int n,i,val;

    printf("Enter size Of Array :\n");
    scanf("%d",&n);

    printf("Enter the Array Elements:\n");
        for(i=0;i<n;i++){
            printf("Array[%d] :",i);
            scanf("%d",&arr[i]);
        }
        
    for(i=0;i<n;i++){
        push(arr[i]);
    }
    for(i=0;i<n;i++){
        val = pop();
        arr[i] = val;
    }

    printf("Reverse Array is :\n");
    for(i=0;i<n;i++){
        printf("%d\n",arr[i]);
    }
}

void push(int val){
    stack[++top] = val;
    
}
int pop(){
    return stack[top--];
}<file_sep>#include<stdio.h>
int main(){
    int n,i;
    int arr[20];
    int smallest,pos;

    printf("Enter Size of Array :\n");
    scanf("%d",&n);

    printf("Enter Elements :\n");
    for(i=0;i<n;i++){
        printf("Array[%d] =",i);
        scanf("%d",&arr[i]);
    }
    pos = 0;
    smallest = arr[0];
    for(i=0;i<n;i++){
        if(smallest > arr[i]){
            smallest=arr[i];
            pos = i;
        }
    }
    printf("Smallest is = %d\n",smallest);
    printf("Position is %d\n",pos);
    return 0;
}<file_sep>#include <stdio.h>
int main(){
    int arr[100];
    int i,n;

    printf("Enter the Size of element : ");
    scanf("%d",&n);

    for(i=0;i<n;i++){
        printf("%d Element ",i);
        scanf("%d",&arr[i]);
    }
    for(i=0;i<n;i++){
        printf("%d Element is %d\n",i,arr[i]);
    }

    return 0;

}<file_sep>#include <stdio.h>
int main(){
    int i,n,m,loc;
    int a[20];
    int b[20];
    printf("Enter the Size First Array :\n");
    scanf("%d",&n);
    printf("Enter First Array Element :\n");
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++){
        printf("Array[%d] = %d\n",i,a[i]);
    }
    
    printf("Enter the Size second Array :\n");
    scanf("%d",&m);
    printf("Enter Second Array Element :\n");
    for(i=0;i<m;i++){
        scanf("%d",&b[i]);
    }
    for(i=0;i<m;i++){
        printf("Array[%d] = %d\n",i,b[i]);
    }

    printf("ENTER LOCATION :\n");
    scanf("%d",&loc);

    for(i=n-1;i>=loc;i--){
        a[i+m]=a[i];
    }

    for(i=0;i<m;i++){
        a[loc+i] = b[i];
    }
    printf("New Elements is :\n");
    for(i=0;i<n+m;i++){
        printf("%d\n",a[i]);
    }

}<file_sep>#include<stdio.h>
#include<stdlib.h>

struct node{
    int data;
    struct node* right;
    struct node* left;
};

struct node* root = NULL;

void append(void);
int length(void);
void display(void);
void addAtBegin(void);
void addAtAfter(void);
void delete(void);

void main(){
    int ch,len;
    while(1){
        printf("Operation of Double linked list\n");
        printf("1.Append\n");
        printf("2.Add at Begin\n");
        printf("3.length\n");
        printf("4.Display\n");
        printf("5.Add at after\n");
        printf("6.Delete\n");
        printf("7.Exit\n\n");

        printf("Enter your Choice :\n");
        scanf("%d",&ch);

        switch(ch){
            case 1: append();
                    break;
            case 2: addAtBegin();
                    break;
            case 3: len = length();
                    printf("Length is : %d\n\n",len);
                    break;
            case 4: display();
                    break;
            case 5: addAtAfter();
                    break;
            case 6: delete();
                    break;        
            case 7: exit(1);
            default: printf("Invalid choice.....\n\n");
        }
    }
}
void append(){
    struct node* temp;
    temp = (struct node*)malloc(sizeof(struct node));
    printf("Enter node data :\n");
    scanf("%d",&temp->data);
    temp->left = NULL;
    temp->right = NULL;

    if(root == NULL){
        root = temp;
    }else{
        struct node* p;
        p = root;
        while(p->right != NULL){
            p = p->right;
        }
        p->right = temp;
        temp->left = p; 
    }
}
void addAtBegin(){
    struct node* temp;
    temp = (struct node*)malloc(sizeof(struct node));
    printf("Enter Node Data :\n");
    scanf("%d",&temp->data);
    temp->left = NULL;
    temp->right=NULL;
    if(root == NULL){
        root = temp;
    }else{
        temp->right = root;
        root->left = temp;
        root = temp;
    }
}
int length(){
    struct node* temp;
    int count = 0;
    temp = root;
    while(temp != NULL){
        count++;
        temp = temp->right;    
    }
    return count;

}
void display(){
    struct node* temp;
    temp =root;
    if(temp == NULL){
        printf("Empty List....\n");
    }else{
        while(temp != NULL){
            printf("%d-->",temp->data);
            temp =temp->right;
        }
        printf("\n\n");
    }
}
void addAtAfter(){
    int loc,i=1;
    struct node* temp,*p;
    printf("Enter location :\n");
    scanf("%d",&loc);
    if(loc > length()){
        printf("Invalid location\n");
    }else{
        struct node* temp;
        temp = (struct node*)malloc(sizeof(struct node));
        printf("Enter node Data :\n");
        scanf("%d",&temp->data);
        temp->right = NULL;
        temp->left = NULL;
        p =root;
        while(loc > i){
            p = p->right;
            i++;
        }
        temp->right = p->right;
        p->right->left = temp;
        temp->left = p;
        p->right = temp;
        
    }
}
void delete(){
    struct node* temp;
    int loc;
    printf("Enter Location :\n");
    scanf("%d",&loc);
    if(loc > length()){
        printf("Invalid location\n");
    }else if(loc == 1){
        temp = root;
        root = temp->right;
        temp->right->left = root;
        temp->left = NULL;
        temp->right = NULL;
        free(temp);
    }else{
        int i = 1;
        struct node* p,*r;
        p =root;
        while(i < loc - 1){
            p = p->right;
            i++;
        }
        r = p->right;
        p->right = r->right;
        r->right->left = p;
        r->left = NULL;
        r->right = NULL;
        free(r);
    }
}<file_sep>#include<stdio.h>
#include<stdlib.h>
struct node{
    int data;
    struct node* link;
};

struct node* root = NULL;
void append();
void addatbegin();
void addatafter();
void delete();
void display();
int length();

int len;

void main(){
    int ch;
    while (1){
        printf("Linked list operations\n\n");
        printf("1.Append :\n");
        printf("2.Add the Begginin :\n");
        printf("3.Add After choice :\n");
        printf("4.Display :\n");
        printf("5.Delete :\n");
        printf("6.length :\n");
        printf("7.Exit \n");

        printf("Enter your Choice :\n");
        scanf("%d",&ch);

        switch (ch)
        {
        case 1: append();
                break;
        case 2: addatbegin();
                break;
        case 3: addatafter();
                break;
        case 4: display();
                break;
        case 5: delete();
                break;
        case 6: len = length();
                printf("length is :%d\n",len);
                break;
        case 7: exit(1);
        
        default: printf("Invalid choice :\n");
        }
    }
    
}
void append(){
    struct node* temp;
    temp = (struct node*)malloc(sizeof(struct node));
    printf("Enter the Node Data :");
    scanf("%d",&temp->data);
    
    temp->link = NULL;

    if (root == NULL){
        root = temp;    
    }else{
        struct node* p;
        p = root;
        while (p->link != NULL){
            p = p->link;
        }
        p->link = temp;
    }
    
}
int length(){
    int count = 0;
    struct node* temp;
    temp = root;

    while(temp != NULL){
        count++;
        temp = temp->link;
        
    }
    return count;
}
void display(){
    struct node* temp;
    temp = root;

    if (temp == NULL){
        printf("Empty list \n");
    }else{
        while (temp != NULL){
            printf("%d-->",temp->data);
            temp= temp->link;
        }
        printf("\n\n");
    }
    
}
void addatbegin(){
    struct node* temp;
    temp = (struct node*)malloc(sizeof(struct node));
    printf("Enter the data ");
    scanf("%d",&temp->data);
    temp->link = NULL;
    if (root == NULL)
    {
      root = temp;
    }else{
        temp->link = root;
        root = temp;
    }
    
}
void addatafter(){
int i=1;
int loc;
struct node* temp,*p;

printf("Enter location :");
scanf("%d",&loc);

if (loc > length()){
    printf("Invalid Locaton \n");
    printf("Length is : %d\n",len);
}
else{
    p = root;
    while(i < loc){
        p = p->link;
        i++;
    }
    temp = (struct node*)malloc(sizeof(struct node));
    printf("Enter node data :\n");
    scanf("%d",&temp->data);
    temp->link = p->link;
    p->link = temp;
}


}   
void delete(){
    int loc = 0;
    struct node* temp;

    printf("Enter the location :");
    scanf("%d",&loc);

    if(loc > length()){
        printf("Invalid Location \n");
    }
    else if(loc == 1){
        temp = root;
        root = temp->link;
        temp->link = NULL;
        free(temp);
    }
    else{
        struct node* p = root;
        struct node* q;
        int i = 1;
        while(i < loc-1){
            p = p->link;
            i++;
        }
        q = p->link;
        p->link = q->link;
        q->link = NULL;
        free(q);
    }
}<file_sep>#include <stdio.h>
#include<stdlib.h>

#define CAPACITY 5
int queue[CAPACITY];

 int front = 0;
 int rear = 0;

void push(void);
void pop(void);
void traverse(void);

 void main(){
     int ch;
     while(1){
         printf("Queue operations !!!!\n");
         printf("1.Push\n");
         printf("2.Pop\n");
         printf("3.Traverse\n");
         printf("4.Exit\n");
        
        printf("Enter your choice :\n");
        scanf("%d",&ch);

        switch(ch){
            case 1: push();
                    break;
            case 2: pop();
                    break;
            case 3: traverse();
                    break;
            case 4: exit(1);
                    break;
            default: printf("Invalid choice!!\n");
        }
     }
 }
 void push(){
     if(CAPACITY == rear){
         printf("List Full...\n");
     }else{
         int ele;
         printf("Enter data :\n");
         scanf("%d",&ele);

         queue[rear] = ele;
         rear++;
     }
 }
 void pop(){
     if(rear == front){
         printf("Empty list...\n");
     }else{
        printf("Delete data is : %d\n",queue[front]);
        for(int i = 0;i<rear;i++){
            queue[i] = queue[i+1];
        }
        rear--;
     }
 }

 void traverse(){
     if(rear == front){
         printf("Empty List...\n");
     }else{
         printf("Queues Elements :\n");
         for(int i=front;i < rear;i++){
             printf("%d\n",queue[i]);
         }
     }
 }<file_sep>#include<stdio.h>
#include<stdlib.h>
struct node
{
    int data;
    struct node* link;
};
struct node* root = NULL;

void main(){
    struct node* temp;
    temp = (struct node*)malloc(sizeof(struct node));
    printf("Enter the Data: ");
    scanf("%d",&temp->data);
    temp->link =root;
    if (root == NULL)
    {
        root = temp;
    }else
    {
        struct node* p;
        p = root;
        while (p->link != NULL)
        {
            p = p->link;
        }
        p->link =temp;
        
    }
    
    
}
<file_sep>#include<stdio.h>
#include<stdlib.h>

struct node{
    int data;
    struct node* link;
};

struct node* root = NULL;

void add(void);
void swap(void);
void display(void);

void main(){
    int ch;
    while(1){
        printf("Swaping using Link list\n\n");
        printf("1.Add\n");
        printf("2.Swap\n");
        printf("3.Display\n");
        printf("4.Exit\n");

        printf("Enter your choice :");
        scanf("%d",&ch);

        switch(ch){
            case 1: add();
                    break;
            case 2: swap();
                    break;
            case 3: display();
                    break;
            case 4: exit(1);
                    
            default: printf("Invalid choice !!1\n");
        }

    }
}
void add(){
    struct node* temp;
    temp = (struct node*)malloc(sizeof(struct node));
    printf("Enter the Node data :\n");
    scanf("%d",&temp->data);
    temp->link = NULL;
    if(root ==  NULL){
        root =temp;
    }else{
        struct node* p;
        p = root;
        while(p->link != NULL){
            p = p->link;
        }
        p->link=temp;

    }
}
void swap(){
    int loc,i=1;
    struct node* p,*r,*q;
    printf("Enter location to swap :\n");
    scanf("%d",&loc);
    p =root;
    while(i < loc-1){
        p = p->link;
        i++;
    }
    q = p->link;
    r = q->link;
    q->link = r->link;
    r->link = q;
    p->link = r;
}
void display(){
    struct node* temp;
    temp =root;
    if(temp == NULL){
        printf("Empty List\n");
    }else{
        while(temp != NULL){
            printf("%d-->",temp->data);
            temp= temp->link;
        }
        printf("\n\n");
    }
}<file_sep>#include <stdio.h>
int main(){
    int n,i,loc,key;
    int arr[20];
    
    printf("Enter Size Of Array :");
    scanf("%d",&n);

    printf("Enter Element :\n");
    for(i=0;i<n;i++){
        scanf("%d",&arr[i]);
    }
    printf("Enter location To Add :");
    scanf("%d",&loc);

    printf("Enter Element to Add :");
    scanf("%d",&key);

    for(i=n-1;i>=loc;i--){
        arr[i+1] = arr[i];
    }
    arr[loc]=key;
    for(i=0;i<n;i++){
        printf("%d\n",arr[i]);
    }
}<file_sep>#include<stdio.h>
#include<stdlib.h>

struct node{
    int data;
    struct node* link;
};
struct node* top = NULL;

void push(void);
void pop(void);
void display(void);

void main(){
    int ch;
    while(1){
        printf("Single Linked list using Stack\n\n");

        printf("1.PUSH\n");
        printf("2.POP\n");
        printf("3.DISPLAY\n");
        printf("4.exit\n\n");

        printf("Enter your Choice :");
        scanf("%d",&ch);
        switch(ch){
            case 1: push();
                    break;
            case 2: pop();
                    break;
            case 3: display();
                    break;
            default: printf("Invalid choice\n\n");
        }
    }
}
void push(){
    struct node* temp;
    temp = (struct node*)malloc(sizeof(struct node));
    printf("Enter node Data :");
    scanf("%d",&temp->data);
    temp->link = top;
    top = temp;
}
void display(){
    struct node* temp;
    if(top==NULL){
        printf("Stack is empty\n");
    }else{
        temp = top;
        while(temp != NULL){
            printf("%d\n",temp->data);
            temp = temp->link;
        }
    }
  

}
void pop(){
    struct node* temp;
    if (top == NULL){
        printf("No ELIMENT\n");
    }else{
        temp = top ;
        printf("Delete : %d\n",temp->data);
        top = top->link ;
        temp->link = NULL;
        free(temp);
    }
    
}