Algorithms and Flow Charts
We will cover following topics
Algorithms And Flow Charts
From this section, three types of problems are asked:
(i) Write an algorithm
(ii) Draw a flowchart
(iii) Write a program in C++
Note: After the syllabus change in 2008, for programming related questions, the language is changed from BASIC to C++, so you may attempt the programming questions related to BASIC by simple writing the logic in C++ instead of BASIC.
Also, for students appearing for IFoS, since syllabus is not changed after 2008, so practice the programming-related questions in both BASIC and C++.
PYQs
Algorithms And Flow Charts
1) Draw a flow chart and write a basic algorithm (in FORTRAN/C/C++) for evaluating y=∫60dx1+x2 using Trapezoidal rule.
[2019, 10M]
2) Write down the basic algorithm for solving the equation: xex−1=0 by bisection method, correct to 4 decimal places.
[2018, 10M]
3) In a certain examination, a candidate has to appear for one major & two major subjects. The rules for declaration of results are marks for major are denoted by M1 and for minors by M2 and M3. If the candidate obtains 75% and above marks in each of the three subjects, the candidate is declared to have passed the examination in first class with distinction. If the candidate obtains 60% and above marks in each of the three subjects, the candidate is declared to have passed the examination in first class. If the candidate obtains 50% or above in major, 40% or above in each of the two minors and an average of 50% or above in all the three subjects put together, the candidate is declared to have passed the examination in second class. All those candidates, who have obtained 50% and above in major and 40% or above in minor, are declared to have passed the examination. If the candidate obtains less than 50% in major or less than 40% in anyone of the two minors, the candidate is declared to have failed in the examinations. Draw a flow chart to declare the results for the above.
[2012, 20M]
4) Draw a flow chart for Lagrange’s interpolation formula.
[2011, 20M]
5) Given 3×3 matrices
A=(aij), B=(bij). Draw programme outline, flow chart and also write a programme in BASIC to enable evaluation of F, given F=5∗(A+B)∗(A−B).
[2007, 30M]
6) Draw a programme outline and a flow chart and also write a programme in BASIC to enable solving the following system of 3 linear equations in 3 unknowns x1, x2 and x3: C∗X=D with C=(cij)3i,j=1, X=(xj)3j=1, D=(di)3i=1.
[2006, 30M]
7) In a certain exam, candidates have to take 2 papers under part A and 2 papers under part B. A candidate has to obtain minimum of 40% in each paper under part A, with an average of 50%, together with a minimum of 35% in each paper under part B, with an aveage of 40. For a complete PASS, an overall minimum of 50% is required. Write a BASIC program to declare the result of 100 candidates.
[2004, 15M]
8) Write a BASIC program for solving the differential equation:
dydx=x2+y2,y(0)=0.1to get y(x), for 0.2≤x≤5 at an equal interval of 0.2, by Runge-Kutta fourth order method.
[2004, 15M]
9) Draw a flow chart and also write a program in BASIC to find one real root of the non linear equation x=ϕ(x) by the fixed point iteration method. Illustrate it to find one real root, correct up to four places of decimals, of x3−2x−5=0.
[2005, 30M]
10) A teacher conducts three tests TEST 1, TEST 2 and FINAL for 50 marks each. Out of the marks scored in the two tests, TEST 1 and TEST 2, he takes the better one and adds to the marks scored in FINAL, so that the total marks scored will be for a maximum 100.
The letter grades will be assigned depending on the amrks scored as per the following norm:
0-39: E
40-49: D
50-59: C
60-74: B
70-100: A
For each student data consisting of name, scores in TEST 1, TEST 2 and FINAL are given. Write a program in BASIC which will print out the names, total marks scored and grade obtained for all 20 students in a class.
[2002, 20M]
11) Draw a flow chart to examine whether a given number is a prime.
[2002, 10M]
12) Write a computer program in BASIC to evaluate the polynomial
a0xn+a1xn−1+a2xn−2+⋯+an−1x+anfor values of x=1.2 (0.2) 2.0.
[2001, 15M]
13) In an examination students are awarded letter grades according to the following scheme:
| Score Range | Letter Grade |
|:------------------------|:-------------|
| Score$\geq$90 | A |
| $80\geq$Score$<$90 | B |
|$70\geq$Score$<$80 | C |
|$60\geq$Score$<$70 | D |
| Score$<$60 | F |
For each score print a message identifying the letter grade. For grade F an additional message ‘This is a falling case’ may be mentioned. Prepare the flowchart for this scheme and write the program in BASIC.
[20M]