Project DSU (4)
Project DSU (4)
Project Report
On
By.
This is to certify that the project report on “Develop project to convert arithmetic
expression prefix & postfix or infix” has been presented subject of object oriented
programing [oop-22316] by, students of SY IF in the partial fulfillment for the award of
Diploma in information technology engineering as per curriculum laid by the
Maharashtra State Board of Technical Education, MUMBAI during the academic year
2022-23
students can request the librarian to add new books by filling the book request form .The
librarian after logging into his account ie admin account can generate various reports such
as student report , issue report, teacher report and book report Overall this project of ours
is being developed to help the students as well as staff of library to maintain the library in
the best way possible and also reduce the human efforts.
DECLARATION
We hereby declare that, Dissertation entitled “Develop project to
convert arithmetic expression prefix & postfix or infix” completed and
submitted for the award of Diploma Engineering in Information Technology
branch, of New Satara College of Engineering And Management (Poly.),Korti,
Pandharpur. It has not been previously presented and to the best of my
knowledge, for the award of diploma engineering title of this or any other
university or examination body.
((2 + 2) * 3)
This is the form that we normally use to write equations. This notation is
called infix notation.
Postfix notation
2 2 + 3 *
In prefix notation, the operators come before their operands. This is also
called Polish notation, or Warsaw notation. Below is the same equation in prefix
notation:
*+ 2 2 3
For the conversion of infix notation into postfix notation, we use the stack data
structure. These are the rules for conversion:
Infix: ((2+2)*3)
)3*)2+2((
(3*(2+2))
*+ 2 2 3
#include <bits/stdc++.h>
using namespace std;
// Function to return precedence of operators
int prec(char c)
{
if (c == '^')
return 3;
else if (c == '/' || c == '*')
return 2;
else if (c == '+' || c == '-')
return 1;
else
return -1;
}
stack<char> st;
string result;
// If an operator is scanned
else {
while (!st.empty()
&& prec(s[i]) <= prec(st.top())) {
result += st.top();
st.pop();
}
st.push(c);
}
}
// Driver code
int main()
{
string exp = "a+b*(c^d-e)^(f+g*h)-i";
// Function call
infixToPostfix(exp);
return 0;
}
Output:
abcd^e-fgh*+^*+i-