Friday, 12 August 2016

Data Structures and Applications(15CS33): Module 2

Data Structures and Applications (15CS33):

Module 2


Find all occurrences of pattern in a string

Find all occurrences of pattern(pat) in a a string(txt)


#include<stdio.h>
#include<string.h>
void main()
{
                char txt[30],  pat[30];
                int m, n;
                int i, j, found = 0;
                printf("\nEnter the main string:");
                gets(txt);
                printf("\nEnter the pattern to be searched: ");
                gets(pat);

                m = strlen(txt);
                n = strlen(pat);

                for(i=0;  i<=m-n;  i++)
                {
                                found  = 1;
                                for(j=0; j<n; j++)
                                {
                                                if(txt[i+j] != pat[j])
                                                {
                                                                found = 0;
                                                                break;
                                                }
                                }
                                if(found == 1)
                                                printf("\n The pattern found at index:%d",  i);
                }
                if(found  ==  0)
                                printf("\n   Pattern not found");
}

Output:
Enter the main string:    hello hii how hii
Enter the pattern to be searched:    hii

The pattern found at index:  6
The pattern found at index:   14

Extract a substring from a string from specified position

Extract a substring (substr) of length n from a string (str) from specified position (pos)


#include<stdio.h>
void main()
{
                char str[20], substr[20];
                int n, pos, i, j=0;

                printf("\nEnter the string:");
                gets(str);
                printf("\nEnter the position:");
                scanf("%d", &pos);
                printf("\nEnter the length of substring:");
                scanf("%d", &n);

                i = pos;
                while(str[i] != '\0'  &&  n>0)
                {
                                substr[j] = str[i];
                                i++;
                                j++;
                                n--;
                }
                substr[j] = '\0';

                printf("\nThe substring is:");
                puts(substr);

}

Output:
Enter the string:               hello hii abc
Enter the position:          2
Enter the length of substring:     5
The substring is:               llo h

Insert a substring to a string at specified position

Insert a substring (str) to a string (txt) at specified position (pos)


#include<stdio.h>
#include<string.h>

void main()
{
          char txt[30], str[30];
          int pos, i, k=0,m,n;
          printf("\nEnter the text: ");
          gets(txt);
          printf("\nEnter the string to be inserted: ");
          gets(str);
          printf("\nEnter the position where to be inserted: ");
          scanf("%d", &pos);
          m = strlen(txt);
          n = strlen(str);

          for(i=m-1; i>=pos; i--)
          {
                    txt[i+n] = txt[i];
          }
           i = pos;
           while(str[k] != '\0')
          {
                  txt[i] = str[k];
                   i++;
                   k++;
           }
           m = m+n;
           txt[m] = '\0';

           printf("\nThe new string is: ");
           puts(txt);
}

Output:
Enter the text: abcdefghij
Enter the string to be inserted: yyyy
Enter the position where to be inserted: 2
The new string is:  abyyyycdefghij

---------------------------------------------------------------------------------------------------
/*Method 2*/

#include<stdio.h>
void main()
{
                char txt[30],  str[30], new[40];
                int pos,  j=0, i=0, k=0;

                printf("\nEnter the text: ");
                gets(txt);
                printf("\nEnter the string to be inserted: ");
                gets(str);
                printf("\nEnter the position where to be inserted: ");
                scanf("%d", &pos);

                while(txt[i] != '\0' )
                {
                                if(i == pos)
                                {
                                                while(str[k] != '\0')
                                                {
                                                                new[j] = str[k];
                                                                j++;
                                                                k++;
                                                }
                                }
                                new[j] = txt[i];
                                j++;
                                i++;
                }
                new[j] = '\0';

                printf("\nThe new string is: ");
                puts(new);
}

Output:
Enter the text:                                            how are you
Enter the string to be inserted:                  abcde
Enter the position where to be inserted:    1

The new string is:                                      habcdeow are you


Copy one string to another without using library function strcpy

Copy one string to another without using library function strcpy


#include<stdio.h>
main()
{
                char s1[10], s2[10];
                int n, i = 0;
                printf("\nEnter string 2: ");
                gets(s2);

                while(s2[i] != 0)
                {
                                s1[i] = s2[i];
                                i++;
                }
                s1[i] = '\0';

                printf("\n String 1 after copying: ");
                puts(s1);
}

Output:
Enter string 2: Hello Hii
String 1 after copying: Hello Hii

Reversing the string without using Library function

Reversing the string without using Library function


#include<stdio.h>
#include<string.h>
void main()
{
                char str[20], rev[20], temp;
                int i=0, j;
                printf("\nEnter the string: ");
                gets(str);

                j = strlen(str) - 1;
                while(i<j)
                {
                                temp = str[j];
                                str[j] = str[i];
                                str[i] = temp;
                                i++;
                                j--;
                }

                printf("\nReversed string: ");
                puts(str);
}

Output:
Enter the string:   newspaper
Reversed string:   repapswen

Also check,
https://tejaswinihbhat.blogspot.in/2016/08/strrev-reversing-string-using-library.html

strrev: Reversing the string using library function

String: strrev(string)

Reversing the string using library function


#include<stdio.h>          
#include<string.h>
main()
{
                char s[60];
                printf("\nEnter string:\t");
                gets(s);
                printf("\nReversed string is:  %s", strrev(s));
}
Output:
Enter string:   Hello How Are You
Reversed string is:  uoY erA woH olleH

strncpy: Copy specified number of characters from one string to another string using library function

String: strncpy(dest, source, n)


Copy specified number of characters from one string to another string using library function


#include<string.h>
main()
{
                char s[60], d[60]="\0";
                printf("\nSource string:\t");
                gets(s);
                strncpy(d, s, 5);
                printf("\nDestination string: %s", d);
}
Output:
Source string:  Hii How Are you

Destination string: Hii H

strcpy: Copy one string to another string using library function

String: strcpy(dest, source)

Copy one string to another string using library function


#include<stdio.h>
#include<string.h>
main()
{
                char s[60], d[60]="\0";
                printf("\nSource string:\t");
                gets(s);
                strcpy(d, s);
                printf("\nDestination string: %s", d);
}
Output:
Source string:  Hii How Are you
Destination string: Hii How Are you

strupr: Convert from Lower case to Upper case using Library function

String: strupr(string)

Convert from Lower case to Upper case using Library function


#include<stdio.h>
#include<string.h>
main()
{
                char s[60];
                printf("\nEnter string:\t");
                gets(s);
                printf("\nString in uppercase: %s", strupr(s));
}

Output:
Enter string:   Hello How Are You
String in uppercase: HELLO HOW ARE YOU

strlwr: Convert from Upper case to Lower case using Library function

String: strlwr(string)

Convert from Upper case to Lower case using Library function


#include<stdio.h>
#include<string.h>
main()
{
                char s[60];
                printf("\nEnter string:\t");
                gets(s);
                printf("\nString in lowercase: %s", strlwr(s));
}
Output:
Enter string:   Hello How Are You
String in lowercase:  hello  how are you

Thursday, 11 August 2016

Length of the string without using library function

Length of the string without using library function

#include<stdio.h>
main()
{
                char s[20];
                int i = 0 ;
                printf("\n Enter a string: ");
                gets(s);

                while(s[i] != '\0')
                {
                                i++;
                }
                printf("\n Length of string: %d", i );
}
Output:
 Enter a string: Hello Hii
 Length of string: 9

strlen: Length of the string using library function

String: strlen(string)

Length of the string using library function


#include<stdio.h>          
#include<string.h>
main()
{
                char s[60];
                printf("\nEnter string:\t");
                gets(s);
                printf("\nLength of string is: %d", strlen(s));
}

Output:
Enter string:   Hello How Are You
Length of string is: 17

Unformatted Input and output functions for string


Unformatted Input and output functions for string


#include<stdio.h>
void main()
{
           char s[10];
           printf("\nEnter a string: ");
           gets(s);                      //unformatted input
           printf("\nEntered string is: ");
           puts(s);                    //unformatted output
}

Output:
Enter a string: How are you
Entered string is: How are you

Unformatted Input and output functions for character

Unformatted Input and output functions for character


#include<stdio.h>
void main()
{
              char c;
              printf("\nEnter a character: ");
              c = getchar();                    //unformatted input
              printf("\nEntered character is: ");
              putchar(c);                     //unformatted output
}

Output:
Enter a character: h
Entered character is: h

Formatted Input and output functions for string

Formatted Input and output functions for string


#include<stdio.h>
void main()
{
         char s[10];
         printf("\nEnter a string: ");
         scanf("%s", s);                  //formatted input

         printf("\nEntered string is: ");
         printf("%s", s);               //formatted output
}

Output:
Enter a string: How are you
Entered string is: How

Formatted Input and output functions for character

Formatted Input and output functions for character

#include<stdio.h>
void main()
{
          char ch;
          printf("\n Enter a character: ");
          scanf("%c", &ch);                          //formatted input
          printf("\n Entered character is: ");
          printf("%c", ch);                          //formatted output
}

Output:

1) Enter a character: h
    Entered character is: h

2) Enter a character: hii
    Entered character is: h

Tuesday, 9 August 2016

Sparse Matrix: Transpose

Sparse Matrix: Transpose

#include<stdio.h>
#include<stdlib.h>
#define MAX 100

typedef struct
{
       int row;
  int col;
       int val;
}sparse;

void readsparse(sparse a[], int m, int n)
{
  int i, j, k, item, p;
 a[0].row = m;
 a[0].col = n;
 k = 1;

printf("\nEnter the elements:\n");
for(i=0; i<m; i++)
{
for(j=0; j<n; j++)
{
scanf("%d", &item);
if(item == 0)
continue;
a[k].row = i;
a[k].col = j;
a[k].val = item;
k++;
}
}
a[0].val = k-1;

printf("\nThe entered sparse matrix is:\n");
printf("\nRow\tColumn\tValue\n");
for(p=0; p<=a[0].val; p++)
{
printf("%d\t", a[p].row);
printf("%d\t", a[p].col);
printf("%d\n", a[p].val);
}
}

void transpose(sparse a[], sparse b[])
{
          int i, j, k, n, p;
          n = a[0].val;

b[0].row = a[0].col;
b[0].col = a[0].row;
b[0].val  = n;

if( n > 0)
       {
                k = 1;
               for(i =  0; i<a[0].col ; i++)
              {
                     for(j=1; j<=n ; j++)
                    {
                           if(a[j].col == i)
                           {
                                 b[k].row = a[j].col;
                                     b[k].col = a[j].row;
                                     b[k].val = a[j].val;
                                     k++;
                            }
                     }
              }
        }

printf("\nThe Transpose sparse matrix is:\n");
printf("\nRow\tColumn\tValue\n");
for(p=0; p<=a[0].val; p++)
{
printf("%d\t", b[p].row);
printf("%d\t", b[p].col);
printf("%d\n", b[p].val);
}
}

void main()
{
int m, n;
sparse a[MAX], b[MAX];
printf("\nEnter  the no of rows and columns:\t");
scanf("%d%d",&m, &n);
readsparse(a, m, n);
transpose(a,b);
}

Output:

Enter  the no of rows and columns:      6      6

Enter the elements:
15   0     0    22   0   -15
0     11   3    0     0   0
0     0     0    -6   0   0
0     0     0    0    0   0
91   0     0    0    0   0
0     0     28  0    0   0

The entered sparse matrix is:

Row     Column  Value
6                6          8
0                0         15
0                3         22
0                5        -15
1                1        11
1                2        3
2                4       -6
4                1       91
5                3       28

The Transpose sparse matrix is:

Row     Column  Value
6               6            8
0               0           15
1               1           11
1               4           91
2               1           3
3               0           22
3               5          28
4               2         -6
5               0        -15

Sparse Matrix

Sparse Matrix

#include<stdio.h>
#include<stdlib.h>
#define MAX 100

typedef struct
{
int row;
int col;
int val;
}sparse;

void readsparse(sparse a[], int m, int n)
{
int i, j, k, item, p;
a[0].row = m;
a[0].col = n;
k = 1;

printf("\nEnter the elements:\n");
for(i=0; i<m; i++)
{
for(j=0; j<n; j++)
{
scanf("%d", &item);
if(item == 0)
continue;
a[k].row = i;
a[k].col = j;
a[k].val = item;
k++;
}
}
a[0].val = k-1;

printf("\nThe entered sparse matrix is:\n");
printf("\nRow\tColumn\tValue\n");
for(p=0; p<=a[0].val; p++)
{
printf("%d\t", a[p].row);
printf("%d\t", a[p].col);
printf("%d\n", a[p].val);
}
}

void main()
{
int m, n;
sparse a[MAX];
printf("\nEnter  the no of rows and columns:\t");
scanf("%d%d",&m, &n);
readsparse(a, m, n);
}

Output:
Enter  the no of rows and columns:      6    6

Enter the elements:
15   0   0   22  0  -15
0    11  3   0    0   0
0    0    0   -6   0   0
0    0    0   0    0   0
91  0    0   0    0   0
0    0    28 0    0   0

The entered sparse matrix is:

Row     Column   Value
6           6                8
0           0                15
0           3                22
0           5                -15
1           1                11
1           2                3
2           3               -6
4           0               91
5           2               28

Polynomial Addtion

Polynomail Addition

#include<stdio.h>
#include<stdlib.h>
#define  MAX_TERMS 100    /* size of terms array */

void Creat_polynomail(int start,int finish);
void Print_polynomial(int start,int finish);
int COMPARE(int exp1,int exp2);
void poly_add(int startA, int  finishA, int startB, int finishB, int *startD,int *finishD);

typedef  struct
{
         float  coef;
         int expon;
} polynomial;

polynomial  terms[ MAX_TERMS];

int avail = 0;

void Creat_polynomail(int start,int finish)
{
printf("\nEnter the polynomial:\n");
          while(start <= finish)
         {
                  printf("\n\tEnter details of term %d:",start);
                  printf("\n\tEnter coeff:    ");
                  scanf("%f", &terms[start].coef);
                  printf("\n\tEnter exp:  ");
                  scanf("%d", &terms[start].expon);
                  start++;
          }
}

void Print_polynomial(int start,int finish)
{
while(start<= finish)
           {
                      printf("(%.2f * x^%d)",terms[start].coef,terms[start].expon);
                      if(start != finish)
                                 printf(" + ");
                      start++;
           }
}

int COMPARE(int exp1,int exp2)
{
           if(exp1<exp2)
                      return  -1;
           else if(exp1 == exp2)
                     return   0;
           else
                  return 1;
}

void attach(float coefficient, int exponent)
{
           if (avail > MAX_TERMS)
         {
                     printf("\nToo many terms in the polynomial \n");
                     exit(1);
          }
          terms[avail].coef = coefficient;
          terms[avail].expon = exponent;
          avail++;
}

void poly_add(int startA, int  finishA, int startB, int finishB, int *startD,int *finishD)
{
           float coefficient;
avail = finishB+1;

           *startD = avail;

           while ( startA <= finishA && startB <=finishB)
          {
                    switch (COMPARE(terms[startA].expon, terms[startB].expon))
{
                              case -1:
                                             attach(terms[startB].coef, terms[startB].expon);
                                             startB ++;
                                             break;
                              case 0:
                                            coefficient = terms[startA].coef + terms[startB].coef;
                                            if (coefficient)
                                                       attach(coefficient, terms[startA].expon);
                                            startA++;
                                            startB ++;
                                            break;
                              case 1:
                                           attach(terms[startA].coef, terms[startA].expon);
                                           startA++;
                    }
          }
           for (; startA <= finishA;  startA++)
                             attach(terms[startA].coef, terms[startA].expon);
           for (; startB <= finishB;  startB++)
                              attach(terms[startB].coef, terms[startB].expon);
            *finishD = avail-1;

    printf("\n startD=%d", *startD);
             printf("\n finishD=%d", *finishD);

printf("\n Resultant polynomial is: \n");
            Print_polynomial(*startD, *finishD);
}

void main()
{
            int startA, finishA;
            int startB, finishB;
            int startD, finishD;
printf("\n Enter start and end for A:  ");
            scanf("%d%d", &startA, &finishA);
            Creat_polynomail(startA, finishA);
            printf("\nThe polynomial A is: \n");
            Print_polynomial(startA, finishA);

             printf("\n\n Enter start and end for B:   ");
             scanf("%d%d", &startB, &finishB);
             Creat_polynomail(startB, finishB);
             printf("\nThe polynomial B is: \n");
             Print_polynomial(startB, finishB);

            poly_add(startA, finishA, startB, finishB, &startD, &finishD);
}
Output:

Enter start and end for A:  0         1

Enter the polynomial:

        Enter details of term 0:
        Enter coeff:    2
        Enter exp:  1000

        Enter details of term 1:
        Enter coeff:    1
        Enter exp:  0

The polynomial A is:
(2.00 * x^1000) + (1.00 * x^0)

Enter start and end for B:   2       5

Enter the polynomial:

        Enter details of term 2:
        Enter coeff:    1
        Enter exp:  4

        Enter details of term 3:
        Enter coeff:    10
        Enter exp:  3

        Enter details of term 4:
        Enter coeff:    3
        Enter exp:  2

        Enter details of term 5:
        Enter coeff:    1
        Enter exp:  0

The polynomial B is:
(1.00 * x^4) + (10.00 * x^3) + (3.00 * x^2) + (1.00 * x^0)

 startD = 6
 finishD = 10

 Resultant polynomial is:
(2.00 * x^1000) + (1.00 * x^4) + (10.00 * x^3) + (3.00 * x^2) + (2.00 * x^0)

Monday, 8 August 2016

2 Dimensional Arrays: Addresses and Values

2 Dimensional Arrays: Addresses and Values 

#include<stdio.h>
void main()
{
           int a[3][4] = {      {10,11,12,13}, {20,21,22,23}, {30,31,32,33}      };
           int i, j;

           for(i=0; i<3;  i++)
                    printf("\n *(a+%d) is %d", i, *(a + i) );

           for(i=0;i<3;i++)
           {
                    for(j=0; j<4; j++)
                   {
                               printf("\n (*(a+%d) + %d) is %d", i, j, (*(a + i) + j) );
                    }
           }

           for(i=0;i<3;i++)
          {
                    for(j=0; j<4; j++)
                   {
                              printf("\n *(*(a+%d) + %d) is %d", i, j, *(*(a + i) + j) );
                   }
          }
}


Output:

 *(a+0) is 2686736
 *(a+1) is 2686752
 *(a+2) is 2686768

--------------------------------------
 (*(a+0) + 0) is 2686736
 (*(a+0) + 1) is 2686740
 (*(a+0) + 2) is 2686744
 (*(a+0) + 3) is 2686748

 (*(a+1) + 0) is 2686752
 (*(a+1) + 1) is 2686756
 (*(a+1) + 2) is 2686760
 (*(a+1) + 3) is 2686764

 (*(a+2) + 0) is 2686768
 (*(a+2) + 1) is 2686772
 (*(a+2) + 2) is 2686776
 (*(a+2) + 3) is 2686780

------------------------------------
 *(*(a+0) + 0) is 10
 *(*(a+0) + 1) is 11
 *(*(a+0) + 2) is 12
 *(*(a+0) + 3) is 13

 *(*(a+1) + 0) is 20
 *(*(a+1) + 1) is 21
 *(*(a+1) + 2) is 22
 *(*(a+1) + 3) is 23

 *(*(a+2) + 0) is 30
 *(*(a+2) + 1) is 31
 *(*(a+2) + 2) is 32
 *(*(a+2) + 3) is 33

Lab Program 3 Stack 15CSL38 Data Structures in C Lab

Lab Program 3:

Design, Develop and Implement a menu driven Program in C for the following operations on STACK of Integers (Array Implementation of Stack with maximum size MAX) 
a. Push an Element on to Stack 
b. Pop an Element from Stack 
c. Demonstrate how Stack can be used to check Palindrome 
d. Demonstrate Overflow and Underflow situations on Stack 
e. Display the status of Stack 
f. Exit 
Support the program with appropriate functions for each of the above operations


#include<stdio.h>
#include<stdlib.h>
#define MAX 5

int s[MAX];
int top = -1;

void push(int item);
int pop();
void palindrome();
void display();

void main()
{
            int choice, item;
            while(1)
            {
                        printf("\n\n\n\n~~~~~~Menu~~~~~~ : ");
                        printf("\n=>1.Push an Element to Stack and Overflow demo ");
                        printf("\n=>2.Pop an Element from Stack and Underflow demo");
                        printf("\n=>3.Palindrome demo ");
                        printf("\n=>4.Display ");
                        printf("\n=>5.Exit");
                        printf("\nEnter your choice: ");
                        scanf("%d", &choice);
                        switch(choice)
                        {
                                    case 1:             printf("\nEnter an element to be pushed: ");
                                                            scanf("%d", &item);
                                                            push(item);
                                                            break;
                                    case 2:             item = pop();
                                                            if(item != -1)
                                                                        printf("\nElement popped is: %d", item);
                                                            break;
                                    case 3:             palindrome();
                                                            break;
                                    case 4:             display();
                                                            break;
                                    case 5:             exit(1);
                                    default:            printf("\nPlease enter valid choice ") ;
                                                            break;
                    }
            }
}

void push(int item)
{
            if(top == MAX-1)
            {
                        printf("\n~~~~Stack overflow~~~~");
                        return;
            }

            top = top + 1 ;
            s[top] = item;
}

int pop()
{
            int item;
            if(top == -1)
            {
                        printf("\n~~~~Stack underflow~~~~");
                        return -1;
            }
            item = s[top];
            top = top - 1;
            return item;
}

void display()
{
            int i;
            if(top == -1)
            {
                        printf("\n~~~~Stack is empty~~~~");
                        return;
            }
            printf("\nStack elements are:\n ");
            for(i=top; i>=0 ; i--)
                        printf("| %d |\n", s[i]);
}

void palindrome()
{
            int flag=1,i;
            printf("\nStack content are:\n");
            for(i=top; i>=0 ; i--)
                        printf("| %d |\n", s[i]);

            printf("\nReverse of stack content are:\n");
            for(i=0; i<=top; i++)
                        printf("| %d |\n", s[i]);

            for(i=0; i<=top/2; i++)
            {
                        if( s[i] != s[top-i] )
                        {
                                    flag = 0;
                                    break;
                        }
            }
            if(flag == 1)
            {
                        printf("\nIt is palindrome number");
            }
            else
            {
                        printf("\nIt is not a palindrome number");
            }
}


Output:

~~~~~~Menu~~~~~~ :
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow demo
=>3.Palindrome demo
=>4.Display
=>5.Exit
Enter your choice: 1
Enter an element to be pushed: 11

~~~~~~Menu~~~~~~ :
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow demo
=>3.Palindrome demo
=>4.Display
=>5.Exit
Enter your choice: 1
Enter an element to be pushed: 12

~~~~~~Menu~~~~~~ :
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow demo
=>3.Palindrome demo
=>4.Display
=>5.Exit
Enter your choice: 1
Enter an element to be pushed: 13

~~~~~~Menu~~~~~~ :
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow demo
=>3.Palindrome demo
=>4.Display
=>5.Exit
Enter your choice: 1
Enter an element to be pushed: 14

~~~~~~Menu~~~~~
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow demo
=>3.Palindrome demo
=>4.Display
=>5.Exit
Enter your choice: 1
Enter an element to be pushed: 15

~~~~~~Menu~~~~~
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow demo
=>3.Palindrome demo
=>4.Display
=>5.Exit
Enter your choice: 1
Enter an element to be pushed: 16
~~~~Stack overflow~~~~

~~~~~~Menu~~~~~
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow demo
=>3.Palindrome demo
=>4.Display
=>5.Exit
Enter your choice: 4

Stack elements are:
|  15  |
|  14  |
|  13  |
|  12  |
|  11  |

~~~~~~Menu~~~~~
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow demo
=>3.Palindrome demo
=>4.Display
=>5.Exit
Enter your choice: 2
Element popped is: 15

~~~~~~Menu~~~~~
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow demo
=>3.Palindrome demo
=>4.Display
=>5.Exit
Enter your choice: 4
Stack elements are:
|  14  |
|  13  |
|  12  |
|  11  |
~~~~~~Menu~~~~~
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow demo
=>3.Palindrome demo
=>4.Display
=>5.Exit
Enter your choice: 2
Element popped is: 14

~~~~~~Menu~~~~~
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow demo
=>3.Palindrome demo
=>4.Display
=>5.Exit
Enter your choice: 2
Element popped is: 13

~~~~~~Menu~~~~~
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow demo
=>3.Palindrome demo
=>4.Display
=>5.Exit
Enter your choice: 2
Element popped is: 12

~~~~~~Menu~~~~~
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow demo
=>3.Palindrome demo
=>4.Display
=>5.Exit
Enter your choice: 2
Element popped is: 11

~~~~~~Menu~~~~~
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow demo
=>3.Palindrome demo
=>4.Display
=>5.Exit
Enter your choice: 2
~~~~Stack underflow~~~~

~~~~~~Menu~~~~~
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow demo
=>3.Palindrome demo
=>4.Display
=>5.Exit
Enter your choice: 4
~~~~Stack is empty~~~~

~~~~~~Menu~~~~~
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow demo
=>3.Palindrome demo
=>4.Display
=>5.Exit
Enter your choice: 1
Enter an element to be pushed: 11

~~~~~~Menu~~~~~
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow demo
=>3.Palindrome demo
=>4.Display
=>5.Exit
Enter your choice: 1
Enter an element to be pushed: 22

~~~~~~Menu~~~~~
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow demo
=>3.Palindrome demo
=>4.Display
=>5.Exit
Enter your choice: 1
Enter an element to be pushed: 11

~~~~~~Menu~~~~~
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow demo
=>3.Palindrome demo
=>4.Display
=>5.Exit
Enter your choice: 3
Stack content are:
|  11  |
|  22  |
|  11  |

Reverse of stack content are:
|  11  |
|  22  |
|  11  |

It is palindrome number

~~~~~~Menu~~~~~
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow demo
=>3.Palindrome demo
=>4.Display
=>5.Exit
Enter your choice: 2
Element popped is: 11

~~~~~~Menu~~~~~
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow demo
=>3.Palindrome demo
=>4.Display
=>5.Exit
Enter your choice: 2
Element popped is: 22

~~~~~~Menu~~~~~
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow demo
=>3.Palindrome demo
=>4.Display
=>5.Exit
Enter your choice: 2
Element popped is: 11

~~~~~~Menu~~~~~
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow demo
=>3.Palindrome demo
=>4.Display
=>5.Exit
Enter your choice: 1
Enter an element to be pushed: 11

~~~~~~Menu~~~~~
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow demo
=>3.Palindrome demo
=>4.Display
=>5.Exit
Enter your choice: 1
Enter an element to be pushed: 22

~~~~~~Menu~~~~~
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow demo
=>3.Palindrome demo
=>4.Display
=>5.Exit
Enter your choice: 1
Enter an element to be pushed: 33

~~~~~~Menu~~~~~
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow demo
=>3.Palindrome demo
=>4.Display
=>5.Exit
Enter your choice: 3
Stack content are:
|  33  |
|  22  |
|  11  |

Reverse of stack content are:
|  11  |
|  22  |
|  33  |

It is not a palindrome number

~~~~~~Menu~~~~~
=>1.Push an Element to Stack and Overflow demo
=>2.Pop an Element from Stack and Underflow demo
=>3.Palindrome demo
=>4.Display
=>5.Exit
Enter your choice: 5



Also Credits to: 
Manoj Taleka  (manoj89biet@gmail.com)

Yashaswini Jogi (jogi.yash@gmail.com)