InterviewSolution
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. |
Write an algorithm to input N numbers and find the largest among them. |
|
Answer» The algorithm as : Step 1: Read N. Step 2 : Let ctr = 1. Step 3: Read Num. Step 4 : large = Num. Step 5: Read next Num. Step 6 : ctr = ctr + 1. Step 7 : If (Num > large) then large = Num. Step 8 : If (ctr < = N) then repeat steps 5 and 6. Step 9: Print large. Step 10: End. |
|
| 2. |
Write an algorithm to find the largest among three numbers. |
|
Answer» The algorithm is defined as : Step 1: Read X, Y, Z. Step 2 : If X > Y continue step 5. Step 3: If Y>Z then print “Y is the largest “and continue step 7. Step 4: Continue step 6. Step 5: If X>Z then print “X is the largest “and continue step 7. Step 6: Print “Z is largest”. Step 7: End. |
|
| 3. |
Explain Algorithm. |
|
Answer» An algorithm is a step by step instructions required to solve any problem. These instructions are in the user’s language that means they are independent of any programming language. |
|
| 4. |
Write an algorithm to calculate area of triangle. |
|
Answer» Step 1: Start. Step 2 : Read a,b,c. Step 3: s=(a+b+c)/2. Step 4 : Area = (s(s-a)(s-b)(s-c))1/2 Step 5 : Print Area. Step 6: Stop. |
|
| 5. |
Write an algorithm to convert temperature from Fahrenheit to Celsius. |
|
Answer» Step 1: Start. Step 2: Read F. Step 3: C=(5(F-32))/9. Step 4: Print C. Step 5: Stop. |
|
| 6. |
Write an algorithm to compute sum of the square of N numbers. |
|
Answer» The algorithm as : Step 1: Read N. Step 2 : Let ctr = 0, sum = 0. Step 3: Read Num. Step 4 : ctr = ctr + 1. Step 5: Compute the square of the number i.e., = sqr (Num * Num). Step 6 : sum = sum * sqr. Step 7: If ctr is less than N then repeat steps 3 to 6. Step 8: Print sum. Step 9: End. |
|
| 7. |
Write an algorithm to compute the sum of odd and even numbers up to N. |
|
Answer» The algorithm as : Step 1: Start. Step 2 : Input N. Step 3 : sume = 0. Step 4 : sumo = 0. Step 5 : ctr = 1. Step 6 : while (ctr < = N). If (ctr mod 2 = 0) sume = sume + ctr else sumo = sumo + ctr. Step 7: Print “sum of even number is” sume. Step 8: Print “sum of odd number is” sumo. Step 9: End. |
|
| 8. |
Write an algorithm to print the bigger of any two unique given numbers. |
|
Answer» The algorithm as : Step 1: Read two numbers A and B. Step 2: Compare A and B. Step 3: If A is greater than B then, print A else print B. Step 4: Stop. |
|
| 9. |
Write an algorithm for calculating the conversion from rupees to dollars. |
|
Answer» The algorithm is defined as follows : Step 1: Start. Step 2: Read the amount in rupees and conversion rate. Step 3: Calculate the equivalent amount in dollars using the following formula: amount in dollars = amount in rupees/conversion rate. Step 4: Write the amount in dollars. Step 5: Stop. |
|
| 10. |
Write some properties of algorithm. |
|
Answer» Some properties of the algorithm are : 1. An algorithm should terminate after the finite number of steps. 2. An algorithm should be simple so that anyone can understand them properly. 3. An algorithm should be universal and lead to a unique solution to the problem. 4. An algorithm should have the capability to handle some unexpected situations which may arise during the solution of a particular problem. 5. An algorithm should be able to solve all problems of a particular type for which it is designed. |
|
| 11. |
Write some characteristics of algorithm. |
|
Answer» Some characteristics of the algorithm are : 1. Each and every instruction should be short and clear. 2. Each instruction should be such that it can be performed in a finite time. 3. One or more instructions should not be repeated infinitely. 4. After performing the instructions the desired result must be obtained. |
|
| 12. |
Write an algorithm to calculate sum of two numbers. |
|
Answer» Step 1: Start. Step 2: Read A, B. Step 3: Sum=A+B. Step 4: Print Sum. Step 5: Stop. |
|
| 13. |
Write an algorithm to calculate simple interest. |
|
Answer» Step 1: Start. Step 2 : Read RR, T. Step 3 : SI=(P*R*T)/100. Step 4 : Print SI Step 5 : Stop. |
|