Posts

Showing posts with the label c program

infix to postfix expression converter in "C" language

 program: #include<stdio.h> void infix_to_postfix(char[],char[]); int precedence(char); void main() { char infix[20],postfix[20]; printf("enter infix string : "); scanf("%s",infix); infix_to_postfix(infix,postfix); printf("\npostfix exp= %s",postfix); } void infix_to_postfix(char infix[],char postfix[]) { char s[20],symbol; int top=-1,i=0,j=0; while(infix[i]!='\0') { symbol=infix[i]; switch(symbol) { case '(':++top;          s[top]=symbol;          break;     case ')':while(s[top]!='(')              {               postfix[j++]=s[top];               top--; }           top--;           break;     case '+':     case '-':     case '*':     case '...

DOUBLE LINKED LIST IMPLEMENTATION

Image
welcome to yocoding, a place where you can find what you need, if not comment what you need.   CODE :  #include<stdio.h> #include<conio.h> #include<stdlib.h> struct Node {   int data;   struct Node *prev,*next; }; struct Node *head=NULL; void insert_beg(int d) {     struct Node *p;     p= (struct Node*)malloc(sizeof(struct Node));     p->data=d;     p->prev=NULL;     if(head == NULL)     {        p->next = NULL;        head=p;     }     else     {        p->next=head;        head->prev=p;        head=p;     } } void insert_end(int d) {    struct Node *p;    p=(struct Node*)malloc(sizeof(struct Node));    p->data=d;    p->next = NULL;    if(head == NULL)    {   ...

IMPLEMENTATION OF QUEUE BY LINKEDLIST : C PROGRAM

Image
  Hey there ,welcome to yocoding. Here is the code for queue by linked list in C programming language. Program code : #include<stdio.h> #include <stdlib.h> struct node {     int data;     struct node *next; }; struct node *rear=NULL,*front=NULL; void enque(int d) {     struct node *p;     p=(struct node *)malloc(sizeof(struct node));     p->data=d;     if(front==NULL)     {         p->next=NULL;         front=p;         rear=p;         return;     }     rear->next=p;     p->next=NULL;     rear=p;     return; } void deque() {     struct node *temp;     if(front==NULL)         printf("queue is empty.\n");     else if(front==rear){         printf("deleted element %d.\n",front->data);   ...

IMPLEMENTATION OF QUEUE BY ARRAY : C PROGRAM

Image
  Here is the C program for implementation of queue using array.  Queue is a data structure.  program code : #include<stdio.h> #include<stdlib.h> int que[6],f=-1;r=-1; void enque(int d) {     if(f==5)     {         printf("queue is full,enque not possible.\n");         return;     }     if(f==-1)     {         f=r=0;         que[r]=d;     }     else{         r++;         que[r]=d;     } } void deque() {     if(f==-1){         printf("list is empty,deletion not possible\n");         return;     }     if(f==r){         printf("deleted element is %d\n",que[r]);         f=r=-1;     }     else{         printf("deleted ele...

Implementation of Stack with Singly Linked List : C Program

Image
  Here is the code for implementation of stack with singly linked list : program code : #include<stdio.h> #include <stdlib.h> struct node {     int data;     struct node *next; }; struct node *top=NULL; void push(int d) {     struct node *newnode=(struct node*)malloc(sizeof(struct node));     newnode->data=d;     newnode->next=NULL;     if(top==NULL)     {         top=newnode;     }     else{         newnode->next=top;         top=newnode;     }     printf("\ndata %d has been pushed (entered to stack).",d); } void pop() {     struct node *p,*temp=top;     if(temp=NULL)     {         printf("\nstack is empty.");         return;     }     p=top;     top=top->next;     free(p);   ...

stack using array : C program

Image
  Here is the implementation of Stack using Array in C : Program code: #include <stdio.h> #define size 10 int stack[size]; int top=-1; void push(int x) {     if(top>=size)     {         printf("\noverflow");     }     else     {         top++;         stack[top]=x;     } } void pop() {     if(top<=0)     {         printf("\nstack is empty.");         return;     }     return stack[top--]; } void display() {     int i;     if(top<0)     {         printf("\nstack is empty");         return;     }     printf("\nstack elements are : ");     for(i=top;i>=0;i--)     {         printf("%d ",stack[i]);     }     printf("\n"); } i...