Add to Favorites    Make Home Page 3231 Online  
 Language Categories  
 Our Services  

Home » C Home » Data Structures Home » Infix To Prefix Conversion

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title Infix To Prefix Conversion
Author Prachi
Author Email prachijpp [at] hotmail.com
Description
Category C » Data Structures
Hits 434250
Code Select and Copy the Code
/*Infix to Prefix And Postfix*/ /*Assignment:5*/ /*Roll No:2102*/ #include<stdio.h> #include<conio.h> #include<string.h> #define MAX 15 #define true 1 #define false 0 /*Structure Decvlaration*/ typedef struct { char data[MAX]; char top; }STK; /*Function Declarations*/ void input(char str[]); void intopre(char str1[],char pre[]); void intopost(char str1[],char post[]); int isoperand(char sym); int prcd(char sym); void push(STK *s1,char elem); int pop(STK *s1); int empty(STK *s2); int full(STK *s2); void dis(char str[]); void main() { STK s; int cs,ans; char str[MAX],pre[MAX],post[MAX]; clrscr(); do /*Using Do-while Loop*/ { clrscr(); printf(" -----Program for Expressions-----"); printf(" Input The String:"); printf(" MENU: "); printf("1.Infix to Prefix "); printf("2.Infix to Postfix"); printf(" 3.Exit"); cs=getche(); switch(cs) /*Using Switch Case*/ { case 1: intopre(str,pre); break; case 2: intopost(str,post); break; case 3: break; default: printf(" Enter a Valid Choise!"); /*Default Case*/ break; } printf(" Do you wish to Continue?(y/n)"); ans=getche(); }while(ans=='y'||ans=='Y'); /*Condition for Do-while loop*/ getch(); } /**************************************************/ /*To Input String*/ /**************************************************/ void input(char str) { printf("Enter the Infix String:"); scanf("%s",str); } /**************************************************/ /*To Covert Infix To Prefix*/ /**************************************************/ void intopre(STK s1,char str1[],char pre[]) { int len,flag; len=strlen(str1); int check=0,cnt=len-1,pos=0; char elem; while(cnt>=0) /*while condition*/ { flag=0; if(isoperand(str1[cnt])) /*Checking for Operand*/ { printf("%c",str1[cnt]); cnt--; pos++; } else { check=prcd(str1[cnt]); while(check==false) { pre[pos]=str1[cnt]; flag=1; pos++; cnt--; } if(flag==0) { elem=pop(&s1); printf("%c",elem); } } } } /**************************************************/ /*To Convert Infix To Postfix*/ /**************************************************/ void intopost(STK s1,char str1[],char post[]) { int len; len=strlen(str1); int check=0,cnt=len-1,pos=0; } /**************************************************/ /*To Check For Operand*/ /**************************************************/ int isoperand(char sym) { if('A'<sym<'Z'||'a'<sym<'z') return(true); return(false); } /**************************************************/ /*To Check The Precedence*/ /**************************************************/ int prcd(char sym) { } /**************************************************/ /*To Display String*/ /**************************************************/ void dis(char str[]) { } /******************************************/ /*Push Function Definition*/ /******************************************/ void push(STK *s1,char elem) { if(!full(s1)) { s1->top++; /*Incrementing top*/ s1->data[s1->top]=elem; /*Storing element*/ } else printf(" Stack is Full!"); } /******************************************/ /*Full Function Definition*/ /******************************************/ int full(STK *s2) { if(s2->top==MAX) /*Condition for Full*/ return(true); return(false); } /******************************************/ /*Pop Function Definition*/ /******************************************/ int pop(STK *s1) { char elem; if(!empty(s1)) { elem=s1->data[s1->top]; /*Storing top stack element in elem*/ s1->top--; /*Decrementing top*/ return(elem); } return(false); } /******************************************/ /*Empty Function Definition*/ /******************************************/ int empty(STK *s2) { if(s2->top==-1) /*Condition For Empty*/ return(true); return(false); }

Related Source Codes

Script Name Author
The Game Opposite as seen on Nokia 2300 Mobile Manikanta
RECURSIVE BALANCED QUICK SORT ashish
Radix Sort ashish
Change your mouse pointer Ashim
The blinking star Shashank
Data Validation Crylittlebaby
To search a file by giving file type like mp3 or mpeg or doc Prashanth SR
Menus Demonstration B.Chidhambaram
Employee Database Project Using C. Reenku Raman Nayak
Creating a Lexical Analyzer in c fahad bader al-buhairi ¦Õ¤ ?¤Ð Ãß??ÝÐÝ
Calendar Program Omkar & Devendra
Stop double Process for start in C Cedrik Jurak
Stop double Process for start in C Cedrik Jurak
Time Scheduler Atiq Anwar
A timepass game between atmost two players Rahul Roy

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions | Important Websites
Copyright ©2003-2024 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=659


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review