Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

Given below is a C++ function to evaluate a postfix expression represented as a string. The below code contains proper comments and some statements are marked specially. Find the statements which will lead to incorrect output.// C++ function to evaluate a given postfix expressionint evaluatePostfix(char* exp){// Create a stack of capacity equal to expression sizestack<int> st;int i;// Scan all characters one by onefor (i = 0; exp[i]; ++i){// If the scanned character is an operand (number here),// push it to the stack.// The isdigit() function is used to check if a particular// character in the given input string is a digit or not.if (isdigit(exp[i]))st.push(exp[i]); // Statement 1// If the scanned character is an operator, pop two// elements from stack apply the operatorelse{int val1 = st.top(); // Statement 2st.pop();int val2 = st.top();st.pop();switch (exp[i]) // Statement 3{case '+': st.push(val2 + val1); break;case '-': st.push(val2 - val1); break;case '*': st.push(val2 * val1); break;case '/': st.push(val2/val1); break;}}}return st.top();}(A) Statement 2(B) Statement 1(C) Statement 3 & Statement 1(D) None of the above

Answer»
2.

Five full-time employees and 6 interns work 12 hours a day and finish a task in 20 days. 8 full-time employees and 18 interns work 10 hours a day and finish the same task in 12 days. How many are working hours per day required if 5 full-time employees and 6 interns work for 30 days to finish the same amount of work? We may assume that changing number of people in a group does not change productivity.(A) 8 hours a day(B) 7 hours a day(C) 6 hours a day(D) 5 hours a day

Answer»