{"id":"1f8d81d8-86f4-45d5-88af-84d1bf19e555","name":"Infix Evaluation","description":"1. You are given an infix expression.\r\n2. You are required to evaluate and print it's value.","inputFormat":"Input is managed for you","outputFormat":"Value of infix expression","constraints":"1. Expression is balanced\r\n2. The only operators used are +, -, *, /\r\n3. Opening and closing brackets - () - are used to impact precedence of operations\r\n4. + and - have equal precedence which is less than * and /. * and / also have equal precedence.\r\n5. In two operators of equal precedence give preference to the one on left.\r\n6. All operands are single digit numbers.","sampleCode":{"cpp":{"code":"#include <bits/stdc++.h>\n#include <ctype.h>\nusing namespace std;\n\nint main(){\n\tstring str;\n\tgetline(cin, str);\n\t// write your code here\n\n\treturn 0;\n}"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main{\r\n \r\n\r\npublic static void main(String[] args) throws Exception {\r\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\r\n String exp = br.readLine();\r\n\r\n // code\r\n }\r\n}"},"python":{"code":"def infix(exp):\n # write your code here \n\n\n\n \nexp = input()\nexp = exp.replace(\" \", \"\")\n\n\ninfix(exp)\n\n# i/p test case\n# 2 + 6 * 4 / 8 - 3"}},"points":10,"difficulty":"easy","sampleInput":"2 + 6 * 4 / 8 - 3","sampleOutput":"2","questionVideo":"https://www.youtube.com/embed/cv_kPZnMxdA","hints":[],"associated":[{"id":"64183121-ff56-4707-95ba-fd44658c78c0","name":"In postfix conversion(Q- Infix Conversion)","slug":"in-postfix-conversion-q-infix-conversion","type":4},{"id":"6afd096a-a1d1-4396-be37-b56d0c0dd2a4","name":"Convert the following infix expression into postfix expression: 2 * ( 6 - 4 + 8 ) / 3 (Q- Infix Conversation)","slug":"convert-the-following-infix-expression-into-postfix-expression-2-6-4-8-3-q-infix-conversation","type":4},{"id":"dd9387e0-fde3-4c17-8b5a-65f09a590f76","name":"In prefix conversion(Q- Infix Evaluation)","slug":"in-prefix-conversion-q-infix-evaluation","type":4}],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"9847c2b3-e3ad-4b1c-97d1-00206b1be68d","name":"Stacks And Queues For Beginners","slug":"stacks-and-queues-for-beginners","type":0},{"id":"37f85652-eb57-4f5d-9853-6695db8b95ba","name":"Infix Evaluation","slug":"infix-evaluation","type":1}],"next":{"id":"4a22aa10-db4b-4120-8e5c-95bf39f5c737","name":"Infix Evaluation","type":3,"slug":"infix-evaluation"},"prev":{"id":"b05f9772-dddd-46ff-b54d-fc89f3a1c175","name":"Sliding Window Maximum","type":3,"slug":"sliding-window-maximum"}}}

Infix Evaluation

1. You are given an infix expression. 2. You are required to evaluate and print it's value.

{"id":"1f8d81d8-86f4-45d5-88af-84d1bf19e555","name":"Infix Evaluation","description":"1. You are given an infix expression.\r\n2. You are required to evaluate and print it's value.","inputFormat":"Input is managed for you","outputFormat":"Value of infix expression","constraints":"1. Expression is balanced\r\n2. The only operators used are +, -, *, /\r\n3. Opening and closing brackets - () - are used to impact precedence of operations\r\n4. + and - have equal precedence which is less than * and /. * and / also have equal precedence.\r\n5. In two operators of equal precedence give preference to the one on left.\r\n6. All operands are single digit numbers.","sampleCode":{"cpp":{"code":"#include <bits/stdc++.h>\n#include <ctype.h>\nusing namespace std;\n\nint main(){\n\tstring str;\n\tgetline(cin, str);\n\t// write your code here\n\n\treturn 0;\n}"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main{\r\n \r\n\r\npublic static void main(String[] args) throws Exception {\r\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\r\n String exp = br.readLine();\r\n\r\n // code\r\n }\r\n}"},"python":{"code":"def infix(exp):\n # write your code here \n\n\n\n \nexp = input()\nexp = exp.replace(\" \", \"\")\n\n\ninfix(exp)\n\n# i/p test case\n# 2 + 6 * 4 / 8 - 3"}},"points":10,"difficulty":"easy","sampleInput":"2 + 6 * 4 / 8 - 3","sampleOutput":"2","questionVideo":"https://www.youtube.com/embed/cv_kPZnMxdA","hints":[],"associated":[{"id":"64183121-ff56-4707-95ba-fd44658c78c0","name":"In postfix conversion(Q- Infix Conversion)","slug":"in-postfix-conversion-q-infix-conversion","type":4},{"id":"6afd096a-a1d1-4396-be37-b56d0c0dd2a4","name":"Convert the following infix expression into postfix expression: 2 * ( 6 - 4 + 8 ) / 3 (Q- Infix Conversation)","slug":"convert-the-following-infix-expression-into-postfix-expression-2-6-4-8-3-q-infix-conversation","type":4},{"id":"dd9387e0-fde3-4c17-8b5a-65f09a590f76","name":"In prefix conversion(Q- Infix Evaluation)","slug":"in-prefix-conversion-q-infix-evaluation","type":4}],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"9847c2b3-e3ad-4b1c-97d1-00206b1be68d","name":"Stacks And Queues For Beginners","slug":"stacks-and-queues-for-beginners","type":0},{"id":"37f85652-eb57-4f5d-9853-6695db8b95ba","name":"Infix Evaluation","slug":"infix-evaluation","type":1}],"next":{"id":"4a22aa10-db4b-4120-8e5c-95bf39f5c737","name":"Infix Evaluation","type":3,"slug":"infix-evaluation"},"prev":{"id":"b05f9772-dddd-46ff-b54d-fc89f3a1c175","name":"Sliding Window Maximum","type":3,"slug":"sliding-window-maximum"}}}
plane

Editor


Loading...

Infix Evaluation

easy

1. You are given an infix expression. 2. You are required to evaluate and print it's value.

Constraints

1. Expression is balanced 2. The only operators used are +, -, *, / 3. Opening and closing brackets - () - are used to impact precedence of operations 4. + and - have equal precedence which is less than * and /. * and / also have equal precedence. 5. In two operators of equal precedence give preference to the one on left. 6. All operands are single digit numbers.

Format

Input

Input is managed for you

Output

Value of infix expression

Example

Sample Input

2 + 6 * 4 / 8 - 3

Sample Output

2

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode