Electrofriends

C program for Operator Precedence

by Ranjith | March 29th, 2010.

C program for Operator Precedence

#include<stdio.h>
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<ctype.h>
void main()
 {
   int i=0,j=0,k=0,p[10];
   char name[20];
   char key[20]={'(',')','&','%','^','*','/','+','-','|',';'};
   clrscr();
   textcolor(2);
   cprintf("---Operator Precedence-----\n");
   cprintf("\nEnter the expression:");
   scanf("%s",&name);
   cprintf("\n---output----\n");
   for(i=0;i<20;i++)
   {
     for(j=0;j<strlen(name);j++)
     {
       char c;
       c=tolower(name[j]);
       if(!isalpha(c)&&!isdigit(c))
        {
          if(key[i]==c)
           {
             printf("\n %c is executed %d(%c %c %c)\n",c,k++,tolower(name[j-1]),c,tolower(name[j+1]));
           }
        }
     }
  }
 getch();
}

Share and Enjoy:
  • Digg
  • Technorati
  • StumbleUpon
  • Twitter
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Reddit
  • Mixx
  • Yahoo! Buzz
  • LinkedIn
  • NewsVine
  • RSS
  • email
Similar Posts:

Leave a Reply

Share and enjoy

    • Digg
    • Facebook
    • Technorati
    • StumbleUpon
    • Twitter
    • Reddit
    • del.icio.us
    • Yahoo! Buzz
Copyright©2009 www.electrofriends.com All Rights Reserved. Powered by Dhyeya