C Programming Tutorial

 
 
 
 
#include<stdio.h>
#include<conio.h>

struct stack
{
    struct stack *back;
    int i;
};

void main()
{
    struct stack *top;
    struct stack *p;
    struct stack *end;
    int ch,user;
    clrscr();
    while(user!=5)
    {
        printf(\"\\n\\t 1. CREATE\");
        printf(\"\\n\\t 2. PUSH\");
        printf(\"\\n\\t 3. POP\");
        printf(\"\\n\\t 4. DISPLAY\");
        printf(\"\\n\\t 5. EXIT\");
        scanf(\"%d\",&user);
        if(user==1)
        {
            end=(struct stack*)malloc(sizeof(struct stack));
            end->back=0;
            printf(\"\\n\\t ENTER THE DATA IN STACK :::: \");
            scanf(\"%d\",&end->i);
            top=end;
        }
        if(user==2)
        {
            p=(struct stack*)malloc(sizeof(struct stack));
            p->back=top;
            printf(\"\\n\\t PUSH THE DATA IN STACK :::: \");
            scanf(\"%d\",&p->i);
            top=p;
        }
        if(user==4)
        {
            p=0;
            p=top;
            while(p!=0)
            {
                printf(\"\\n\\t %d-->\",p->i);
                p=p->back;
            }
        }
        if(user==3)
        {
            printf(\"\\n\\t DATA THAT IS POPPED IS ::: %d\",top->i);
            p=top->back;
            free(top);
            top=p;
        }
    }
    getch();
}

    Related Post:
  1. Program to calculate average of the elements of an array and then the average deviation using barrier

  2. Program that accepts characters in lower case, stores them in an array and prints them in the upper-case and vice - versa

  3. delete and insert anode at end in doubly link list.

  4. PROGRAM USING WHILE LOOP TO DO SUM OF DIGITS OF THE NUMBER. NO IS - 12345 ANS IS 15

  5. Program to solve the backward dependancy for the following equation using Fair way - x[i]=x[i-1]+y[i]

  6. Program to find sum, average and deviation of input numbers using parallel processing

  7. Program to multiply two nXn matrix using indirect scheduling in two dimensional matrix

  8. Writing strings using %s format

  9. Bubble sort

  10. Program to compare one string s2 to another string s1. Print the difference of first unmatched characters (Without Using strcmp function)

  11. Program to calculate average of the elements of an array and then the average deviation using race condition

  12. Program to print string in different pattern

  13. Program to check entered string is palindrome or not

  14. Program to get and set System Date using Interrupt 21h

  15. Program to find the factorial of a given number using function declaration

  16. PROGRAM TO FIND ANSWER OF THE FOLLOWING SERIES. INPUT STEPS FROM KEYBORD. SUM=X-X3/3!+X5/5!-X7/7!+...(TAKE VALUE OF X ALSO).

  17. Program to convert an expression in postfix form to an infix form

  18. Program to get string after user specified position

  19. Program to draw rectangle and arrow using character as shown in description

  20. Program to convert an Infix expression to Prefix form

 
 
Didn't find what you were looking for? Find more on Stack using linked list