The greatest mistake you can make in life is to be continually fearing you will make one

Thursday 11 February 2010

C Programs Based on Stack

Program 1: Write a C program to implement stack operations push and pop using array.

Program 2: Write a C program to implement stack operations push and pop using Linked List.

Program 3:Design an algorithm,using a stack to read five characters from a keyboard and display them in reverse order.

Program 4:Design an algorithm,using a stack,which will convert a decimal number to binary.

Program 5:Design an algorithm using a stack,which will test whether an input string is palindromic or not

Program 6:Write a C function to copy one stack to another assuming the stack is implemented using array

Program 7:Write a C function to copy one stack to another assuming the stack is implemented using Linked list

5 comments:

  1. Write a C program to implement stack operations push and pop using Linked List.

    ReplyDelete
  2. #include
    #include
    #define SIZE 5
    int top=-1;
    int s[SIZE];
    void push(int);
    int pop();
    void display();
    void main()
    {
    int ch;
    int item,y;
    clrscr();
    printf("menu");
    printf("\t\n1.push");
    printf("\t\n2.pop");
    printf("\t\n3.display");
    printf("\t\n4.exit");
    do
    {
    printf("\n enter ur choice");
    scanf("%d",&ch);
    switch(ch)
    {
    case 1:printf("\n\t enter the elements");
    scanf("%d",&item);
    push(item);
    break;
    case 2:y=pop();
    printf("\n\t deleted value is %d",y);
    break;
    case 3:display();
    break;
    case 4: exit(0);
    break;
    default :printf("invalid choice");
    break;
    }
    }while(ch<=4);
    }
    void push(int item)
    {
    if(top==SIZE-1)
    printf("\t stack overflow");
    else
    {
    top++;
    s[top]=item;
    }
    }
    int pop()
    {
    int y;
    if(top==-1)
    printf("\n\t the stack is underflow");
    else
    {
    y=s[top];
    top--;
    }
    return y;
    }
    void display()
    {
    int i;
    for(i=top;i>=0;i--)
    printf("%d\t",s[i]);
    }

    ReplyDelete
  3. wap to implement stack using array,the array should ccontain names

    ReplyDelete
  4. Keep this going please, great job!

    my web site: best registry cleaner
    Also see my web page :: registry cleaner

    ReplyDelete