Tuesday, March 26, 2013

Infix to postfix conversion


Infix to postfix

#include
#include
#include
int isp(char);
int icp(char);
void main()
{
char s[50],q[50],p[50],ch,item;
int i,n,len,top=-1,ic,is,j=0;
clrscr();
top=top+1;
s[top]='$';
printf("\nEnter expression:");
gets(q);
len=strlen(q);

for(i=0;i
{
ch=q[i];
if(ch=='(')
{
top=top+1;
s[top]=ch;       //push '(' to stack
}
else if(ch=='+'||ch=='-'||ch=='*'||ch=='/'||ch=='^')    /* on operator*/
{
 is=isp(s[top]);
 ic=icp(ch);

  if(ic
  {
   item=s[i];    //pop from stack on isp>icp
   top=top-1;
   p[i]=item;
  }
 top=top+1;
 s[top]=ch;       //push operator to stack
}

else if(ch==')') /* on ')' para */
{
 while(s[top]!='(')
 {
 p[j]=s[top];
 j++;
 top=top-1;
 }
 top=top-1;
}

else            /* on operand */
{
 p[j]=ch;
 j++;
}
}

printf("Postfix expression is:\n");
for(i=0;i
{
printf("%c",p[i]);
}
getch();
}
int isp(char ch)
{
switch(ch)
{
case '+':return(2);

case '-':return(2);

case '*':return(4);

case '/':return(4);

case '^':return(5);

case '(':return(0);

case ')':return(0);
default:return(0);
}
}
int icp(char ch)
{
switch(ch)
{
case '+':return(1);
case '-':return(1);
case '*':return(3);
case '/':return(3);
case '^':return(6);
case '(':return(9);
case ')':return(0);
default:return(0);
}
}

Prefix Evaluation


Prefix Evaluation.


#include
#include
#include
#include
int top=-1;
int pop(int s[])
{
int a;
a=s[top];
top=top-1;
return a;
}
int push(int c,int s[])
{
top=top+1;
s[top]=c;
return 0;
}
int operation(int a,int b,char ch)
{
switch(ch)
{
case '+':return(a+b);
case '-':return(a-b);
case '*':return(a*b);
case '/':return(a/b);
case '^':return(pow(a,b));
default:return(0);
}
}
void main()
{
int i,len,s[50],a,b,c;
char p[50],ch;
clrscr();
printf("Enter expression:\n");
gets(p);
len=strlen(p);
for(i=len-1;i>=0;i--)
{
ch=p[i];
if(ch=='+'||ch=='-'||ch=='*'||ch=='/'||ch=='^')
{
a=pop(s);
b=pop(s);
c=operation(a,b,ch);
push(c,s);
}
else
{
c=atoi(&ch);
push(c,s);
}
}
printf("Result: %d",pop(s));
getch();
}

Friday, August 19, 2011

A trip to "Elaveezhapoonchira" with robin :)







ഒരു ഉച്ച വട്ട്വളരെ നാളത്തെ ആഗ്രഹം സാധിക്കാനായി അങ്ങനെ ഞാനും റോബിനും  ഇലവീഴാപൂന്ചിറ യാത്ര നടത്തി.. എന്റെ lover ന്റെ കൂടെ പോകണം എന്നായിരുന്നു ആദ്യം തീരുമാനിച്ചത്(ഞാന്‍). അത് നടക്കിലാ എന്ന് ഉറപ്പായതോടെയാണ് റോബിന്റെ കൂടെ പോകമെന്നുവെച്ചു.

പോയ വഴിയില്‍ കോളേജില്‍ കയറേണ്ടി വന്നു. അവിടെ ഒരാള്‍ എന്നെ കത്ത് നില്‍ക്കുന്നുന്ടരുന്നു (രഹസ്യം !) .  എന്റെ ഒരു സാധനം അയാളില്‍ നിന്ന് വാങ്ങി യാത്രപറഞ്ഞു വീണ്ടും മുന്‍പോട്ടു..

          
പാലയില്‍ നിന്നും ഏകദേശം 18 km  പോകണം ഈ സ്ഥലത്തേക്ക്. തൊടുപുഴ റൂട്ടില്‍ പോയി കൊല്ലപ്പല്ലിയില്‍ നിന്നും റൈറ്റ് തിരിഞ്ഞു പിന്നെ  കുറെ അങ്ങനെ പോണം. മേലുകാവ് junction - ല്‍  നിന്നും ലെഫ്റ്റ് തിരിഞ്ഞു 3 -4 km  ചെന്നിട്ടു വീണ്ടും റൈറ്റ് . ആ വഴി കയറാന്‍ എന്റെ കിച്ചു കുറെ പണി പെട്ടു(ഭയങ്കര കയറ്റം ! ). ഒരു 2 km  കഴിഞ്ഞു ലെഫ്റ്റ്, ആ കയറ്റം കയറി  കഴിഞ്ഞാല്‍ പിന്നെ കുറെ നടക്കാം.  




My coooool Glass , Helmet ("ടുട്ടു ,കിട്ടു")



കിച്ചുനെ ഒരു വീടിന്റെ മുന്‍പില്‍ വെച്ചിട്ട് ഞങ്ങള്‍ പിന്നേം നടന്നു(പാവം, കുറെ നേരം അവിടിരുന്നു). കുത്തനെ ഉള്ള കയറ്റമായിരുന്നു പിന്നെ , മഴക്കുള്ള എല്ലാ chance ഉം ഉണ്ടാരുന്നു. വീടുമുതല്‍ പാല വരെ  നനയമെങ്കില്‍ പിന്നെ ഇവിടെ നനയതില്ലേ... ! (ഞങ്ങളോടാ കളി... :D ) . മഞ്ഞു മൂടിയ പ്രദേശം എന്റെ എല്ലാ വികരങ്ങളിലും മുകളിലായി. ! !



   നല്ല വിശപ്പ്‌... :)   കാശ് ലഭിക്കുന്നതിന്റെ ഭാഗമായി ഞങ്ങള്‍ ഫുഡ്‌ വീട്ടില്‍ നിന്ന് കൊണ്ട് വന്നിരുന്നു. ;)   ജനവാസമില്ലാത്ത ഒരു വെള്ളച്ചാട്ടത്തിന്റെ അടുത്തായിരുന്നു ഞങ്ങള്‍ അപ്പോള്‍. അവിടെ ഒരു  പാറക്കെട്ടില്‍ ഇരുന്നു ഞങ്ങള്‍ കഴിച്ചു. എവിടെ നിന്നോ ഒരു പറ്റിയും വന്നു ഞങ്ങളുടെ ഫുഡ്‌ ഷെയര്‍ ചെയ്യാന്‍ . അവനുള്ള വക ഞാന്‍ മാറ്റി വെച്ച് :D..(പാവം ,അവനും ജീവിക്കേണ്ടേ..).


ഫുഡ്‌ കഴിഞ്ഞു  വീണ്ടും  മുകളിലേക്ക്  കയറാന്‍  തുടങ്ങി
..

ആ ചിരി കണ്ടോ ... !






അങ്ങനെ മലമുകളില്‍  അവിടെ എന്ത് സംഭവിച്ചു . .?        കാത്തിരുന്ന് വായിക്കു അടുത്ത ലക്കം മനോരമ ആഴ്ച്ചപതിപ്പല്ല .. ! എന്റെ ബ്ലോഗ്‌ :D

എന്തിനോ വേണ്ടിയുള്ള യാത്രകള്‍ -part 1 will be continued . . . . ;

Saturday, November 27, 2010

Soo soRRy

Iniyum.....     

Iniyum My LOve il oru post undakum ennum karuthiyilla.. Pakshe ezhuthendi vannu..

                                    Innu avalude 20 -)o Birth day aanu.. First Of aLL , "many many happy returns f the daY".. Kazhinja b'day ithra pettannu kazhinjo,? ennu njan chinthikkukayayirunnu.. Ellam valare pettannanu nadakkunnathu alle..?

EE b'day kku avalkku gift kodukkano vendayo ennu valare chinthichu...; oduvil theerumanichu, kodukkam ; pakshe athu avalkku othiri ishtapedunnatho allenkil aval aagrahikkunnatho aayirikkanam ennu thonni.. Ippol oru prasnam njan kaaranam maattan sadhichal athaayirikkum eetavum nalla gift, ippolathe avalude oru prblm njananu, athukondu ini muthal avale yadhoru vidhathilum contact cheyyathirikkan theerumanichu(so i removd her 4m ma orkut accnt first)....

                                         Iniyum ninakku njan enthu tharanaa..?
Ithil kooduthal onnum ente kaiyil illa(this is d most painful gift from me..) ..




 Bye ..

                                                                                                                     _kichu

Sunday, October 24, 2010

pp and Me

                          "PP" and meee 

                                Ini ulla ente postukal ente oru Best frnd ne kurichanu.   Ennilekku vannittu orupadu nalayilla enkilum enne orupadu maattan aa frnd nu kazhinjittundu... Ini 'aval' aayirikkum nammude kadha nayika..!! 



                                                                                      _kichu

Tuesday, September 21, 2010

End oF "My LovE"

This is may be the last post of the "My LovE ,

                
       marakkanavatha ormmakalayi avasanicha ente love ivide njan avasanippikkunnu,,

verum 4 post maathramano ente love ennu chothichal ente utharam muttum.....
kaaranam athil kooduthal onnum ivide thurannu pattilla, dat s iT.


                               jeevithathil ennum ormmikkanum chilappol chunthikkanum kure kazhiyumbol orthu chirikkanum okkeyano ithu.? ariyilla... (enthino thonniyorishtam,lle? !!)

                               ee post vaayichal eetavum santhoshikkunnathu ente lover thanne aayirikkum(ente neerali piduthathil ninnum rakshapettallo ennorthu..!!) , orupadu prblms ulla kuttiya... njanyittu enthina kooduthal undakkuthu, alle..?


                                But der r 2 questions are remaining in ma mind..." -
       1. njan avale orikkalenkilum oru frnd mathramayittu kandirunno..? (illa..)
      2. vere ethrayo penkuttikal undayirunnittum njan enthina avale thanne premichathu..?   (???)   "


                                  utharam kittatha chodyavumayi veendum munpottu...!!!

                                                                                                                           


                                                                                                                                        _kichu

                                                       
(NB: njan ithuvare paranja ee kadhayum, kadhapathrangalum, chilappol sankalpikam mathram aayirikkum. ithinu jeevichirikkunnavarumayo marichavarumayo yaadhoru bandhavum illa...(adhava undennu thonniyal athu ningalude thonnal mathram aayirikkum !))



Monday, September 20, 2010

wiLL u cross tHe skY for me...??

   Always keeping in ma mind.....!!  Bcoz, i loved her for a moment


           ippol enikku ella penkuttikaleyum manasilakkan sadhikkunnu(bcoz nw i knw her !!)..

enne oru valiya paadam padippikkan vendiyayirunno ithellam...?

May be..;

orikkalum ennile oru chinthayilum aval kadannu varathirikkatte ennu njan mattu "nirasha kamukan"mare pole
chinthichilla(still in love area.!!(no babe !)).. kaaranam enikkariyam enikku avale orikkalum verukkan kazhiyilla ennu...

athu njan palappolum paranjittundu..ippolum athu thanne parayanam ennundu...@@

  ippol njan avale maximum avoid cheyyunnundu, athu vere onnum kondallla...., ente manasu veendum kai vittu pokathirikkana..... i knw avoidance is the most painful feeling in the world(i felt dat!!)..
sorry parayunnathu ente style allathathu kondu parayilla...


enikkum athe ippol pattu... enne ishtamalla ennu paranja pennine njan ente "sister o friend o" aayi kandu samadhanikkan paranjal athu nadakkilla...! DAts mEE.'

                                              marichalum marakkatha chila ormmakal ennokke nammal parayarille athupole onnayirunnu ente ee "First LoVe"..!



                     



                                                                                          _kichu