Posts

Showing posts with the label coding

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 '...

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.