Posts

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 '^':     case '/':           while(precedence(symbol)<=precedence(s[top]) && top!=-1)                    postfix[j++]=s[top--];    

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)    {       p->prev=NULL;       head=p;    }    else    {       struct Node *q = head;       while(q-> next != NULL)          q = q-> next;       q-> next = p;       p-> prev = q;    }   } void insert_pos(int d,int pos) {    int i;    struct Node *p;    p=(struct Node*)malloc(sizeof(

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);         free(front);         front=NULL;     }     else{         printf("deleted element %d.\n",front->data);         temp=front;         front=front->next;         free(temp);     }     return; } void display() {     struct node *temp=front;    

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 element is %d\n.",que[f]);         f++;         return;     } } void display() {     int i;     if(f==-1){         printf("queue is empty.\n");         return;     }     printf("queue elements are : ");     for(i=f;i<=r;i++)         printf("%d ",que[i]);     printf("\n"); } int main(

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);     printf("\ntop element has been poped(deleted)."); } void display() {     struct node *p=top;     if(p==NULL)     {         printf("\nstack is empty.");         return;     }     printf("\nstack elements are : ");     while(p!= NULL)     {

Basic C++ class and object program

Image
  This is a basic program of class and object C++ : program : #include <iostream> using namespace std; class age {     int age;     char name[2]; public:     void get()     {         cout<<"enter your age and name: ";         cin>>age>>name;     }     void dis()     {         cout<<"name is "<<name<<",age is "<<age;     } }; int main() {     age a1;     a1.get();     a1.dis();     return 0; } output :

swapping first and last digits of a number :Python Program

Image
  Here is the program for swapping first and last digits of a number in Python programming language program code : n=int(input("number:")) last=n%10 n=int(n/10) n1=str(n) n2=str(1) n6=str(1) for i in range(len(n1)-1):     n2=n2+str(0)     n6=n6+str(0) n6=int(n6) n2=int(n2) n5=int(n/n6) n3=n%n2 print(n5) n4=str(last)+str(n3)+str(n5) print(int(n4)) output : enter number :284517 784512 happy coding. comment what you need.