0% found this document useful (0 votes)
1K views

Flow Chart Questions With Answers

Uploaded by

Naveenraj Raj
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views

Flow Chart Questions With Answers

Uploaded by

Naveenraj Raj
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 31

Flowchart to print the Even numbers between 9 and 100.

Flowchart for printing odd numbers less than a given number. It should also calculate their sum and
count
: Flowchart for the calculate the average from 25 exam scores

Flowchart to calculate the area of circle.


Algorithm
An algorithm is defined as sequence of steps to solve a problem (task). The steps
must be finite, well defined and unambiguous. Writing algorithm requires some thinking.
Algorithm can also be defined as a plan to solve a problem and represents its logic. Note that
an algorithm is of no use if it does not help us arrive at the desired solution
Algorithm characteristics
1. It should have finite number of steps. No one can be expected to execute infinite number of
steps.
2. The steps must be in order and simple
3. Each step should be defined clearly i.e. without un-ambiguity (without doubtfulness)
4. Must include all required information
5. Should exhibit at least one output

Flowchart
A flowchart is a pictorial (graphical) representation of an
algorithm. A flowchart is drawn using different kinds of
symbols. A symbol is used for a specific purpose. Each
symbol has name.
Algorithm Flowchart Program

An algorithm is defined Set of instructions. Instruct


as sequence of steps to solve a A flowchart is pictorial (graphical) command to the computer t
problem (task). representation of an algorithm. some task.

Algorithm can also be defined as a A picture is worth of 1000 words. We


plan to solve a problem and can understand more from picture than Implementation of Algorith
represents its logic. words. flowchart
Different algorithms have different performance characteristics to solve the
same problem. Some algorithms are fast. Some are slow. Some occupy
more memory space. Some occupy less memory space. Some are
complex and some algorithms are simple.
Logically algorithm, flowchart and program are the same.
Q1. Create a program to compute the volume of a sphere. Use the formula: V = (4/3)
*pi*r where pi is equal to 3.1416 approximately. The r is the radius of sphere. Display the
3

result.

Q2. Write a program the converts the input Celsius degree into its equivalent Fahrenheit
degree. Use the formula: F = (9/5) *C+32.
Q3. Write a program that converts the input dollar to its peso exchange rate equivalent.
Assume that the present exchange rate is 51.50 pesos against the dollar. Then display the
peso equivalent exchange rate.

Q4. Write a program that converts an input inch(es) into its equivalent centimeters. Take
note that one inch is equivalent to 2.54cms.
Q5. Write a program that exchanges the value of two variables: x and y. The output must
be: the value of variable y will become the value of variable x, and vice versa.

Q6. Design a program to find the circumference of a circle. Use the formula: C=2πr, where π
is approximately equivalent 3.1416.
Q7. Write a program that takes as input the purchase price of an item (P), its expected
number of years of service (Y) and its expected salvage value (S). Then outputs the yearly
depreciation for the item (D). Use the formula: D = (P – S) Y.

Q8. Swapping of 2 variables without using temporary (or 3 variable).


rd
Q9. Determine the most economical quantity to be stocked for each product that a
manufacturing company has in its inventory: This quantity, called economic order quantity
(EOQ) is calculated as follows: EOQ=2rs/1 where: R= total yearly production requirement
S=set up cost per order I=inventory carrying cost per unit.
Q10. Write a program to compute the radius of a circle. Derive your formula from the given
equation: A=πr², then display the output.

flowchart to check if a given number is odd or even

Algorithm

1. Use Modulus Operator ( % ) to check if the remainder obtained after


dividing the given number N by 2 is 0 or 1.
2. If the remainder is 0, print “Even”
3. If the remainder is 1, print “Odd”.
Pseudocode to Find Whether a Number is Even or Odd

READ number
remainder=number%2
IF remainder==0
WRITE "Even Number"
ELSE
WRITE "Odd Number"
ENDIF

algo and flowchart to calculate the Sum of First n Numbers

Algorithm
1Input : input number n
2Step 1: Start
3Step 2: Read number n Step 3: Declare sum to 0 and i to 1
4Step 4: Repeat steps 5 to 7 until i <= n
5Step 5: update sum as sum = sum + i
6Step 6: increment i
7Step 7: Print sum
8Step 8: Stop
9Output: sum
QUESTIONS TO CREATE ALGORITHM, FLOWCHART and PSEUDOCODE

https://www.brainkart.com/article/Simple-Strategies-For-Developing-
Algorithms_35899/

Write an algorithm to find area of a rectangle

Step 1: Start
Step 2: get l,b values
Step 3: Calculate A=l*b
Step 4: Display A
Step 5: Stop

BEGIN
READ l,b
CALCULATE A=l*b
DISPLAY A
END

Write an algorithm for Calculating area and circumference of circle

Step 1: Start
Step 2: get r value
Step 3: Calculate A=3.14*r*r
Step 4: Calculate C=2.3.14*r
Step 5: Display A,C
Step 6: Stop

BEGIN
READ r
CALCULATE A and C
A=3.14*r*r
C=2*3.14*r
DISPLAY A
END

Write an algorithm for Calculating simple interest

Step 1: Start
Step 2: get P, n, r value
Step3:Calculate
SI=(p*n*r)/100
Step 4: Display S
Step 5: Stop

BEGIN
READ P, n, r
CALCULATE S
SI=(p*n*r)/100
DISPLAY SI
END

Write an algorithm for Calculating engineering cutoff

Step 1: Start
Step2: get P,C,M value
Step3:calculate
Cutoff= (P/4+C/4+M/2)
Step 4: Display Cutoff
Step 5: Stop

BEGIN
READ P,C,M
CALCULATE
Cutoff= (P/4+C/4+M/2)
DISPLAY Cutoff
END

To check greatest of two numbers

Step 1: Start
Step 2: get a,b value
Step 3: check if(a>b) print a is greater
Step 4: else b is greater
Step 5: Stop

BEGIN
READ a,b
IF (a>b) THEN
DISPLAY a is greater
ELSE
DISPLAY b is greater
END IF
END

To check leap year or not

Step 1: Start
Step 2: get y
Step 3: if(y%4==0) print leap year
Step 4: else print not leap year
Step 5: Stop

BEGIN
READ y
IF (y%4==0) THEN
DISPLAY leap year
ELSE
DISPLAY not leap year
END IF
END
To check positive or negative number

Step 1: Start
Step 2: get num
Step 3: check if(num>0) print a is positive
Step 4: else num is negative
Step 5: Stop

BEGIN
READ num
IF (num>0) THEN
DISPLAY num is positive
ELSE
DISPLAY num is negative
END IF
END

To check odd or even number

Step 1: Start
Step 2: get num
Step 3: check if(num%2==0) print num is even
Step 4: else num is odd
Step 5: Stop

BEGIN
READ num
IF (num%2==0) THEN
DISPLAY num is even
ELSE
DISPLAY num is odd
END IF
END

To check greatest of three numbers

Step1: Start
Step2: Get A, B, C
Step3: if(A>B) goto Step4 else goto step5
Step4: If(A>C) print A else print C
Step5: If(B>C) print B else print C
Step6: Stop

BEGIN
READ a, b, c
IF (a>b) THEN
IF(a>c) THEN
DISPLAY a is greater
ELSE
DISPLAY c is greater
END IF
ELSE
IF(b>c) THEN
DISPLAY b is greater
ELSE
DISPLAY c is greater
END IF
END IF
END
Write an algorithm to check whether given number is +ve, -ve

or zero.

Step 1: Start
Step 2: Get n value.
Step 3: if (n ==0) print “Given number is Zero” Else goto step4
Step 4: if (n > 0) then Print “Given number is +ve”
Step 5: else Print “Given number is -ve”
Step 6: Stop

BEGIN
GET n
IF(n==0) THEN
DISPLAY “ n is zero”
ELSE
IF(n>0) THEN
DISPLAY “n is positive”
ELSE
DISPLAY “n is positive”
END IF
END IF
END

Write an algorithm to print all natural numbers up to n

Step 1: Start
Step 2: get n value.
Step 3: initialize i=1
Step 4: if (i<=n) go to step 5 else go to step 8
Step 5: Print i value
step 6 : increment i value by 1
Step 7: go to step 4
Step 8: Stop
BEGIN
GET n
INITIALIZE i=1
WHILE(i<=n) DO
PRINT i
i=i+1
ENDWHILE
END

Write an algorithm to print n odd numbers

Step 1: start
step 2: get n value
step 3: set initial value i=1
step 4: check if(i<=n) goto step 5 else goto step 8
step 5: print i value
step 6: increment i value by 2
step 7: goto step 4
step 8: stop

BEGIN
GET n
INITIALIZE i=1
WHILE(i<=n) DO
PRINT i
i=i+2
ENDWHILE
END
Write an algorithm to print n even numbers

Step 1: start
step 2: get n value
step 3: set initial value i=2
step 4: check if(i<=n) goto step 5 else goto step8
step 5: print i value
step 6: increment i value by 2
step 7: goto step 4
step 8: stop

BEGIN
GET n
INITIALIZE i=2
WHILE(i<=n) DO
PRINT i
i=i+2
ENDWHILE
END

Write an algorithm to print squares of a number

Step 1: start
step 2: get n value
step 3: set initial value i=1
step 4: check i value if(i<=n) goto step 5 else goto step8
step 5: print i*i value
step 6: increment i value by 1
step 7: goto step 4
step 8: stop
BEGIN
GET n
INITIALIZE i=1
WHILE(i<=n) DO
PRINT i*i
i=i+2
ENDWHILE
END

Write an algorithm to print to print cubes of a number


Step 1: start
step 2: get n value
step 3: set initial value i=1
step 4: check i value if(i<=n) goto step 5 else goto step8
step 5: print i*i *i value
step 6: increment i value by 1
step 7: goto step 4
step 8: stop

BEGIN
GET n
INITIALIZE i=1
WHILE(i<=n) DO
PRINT i*i*i
i=i+2
ENDWHILE
END

Write an algorithm to find sum of a given number


Step 1: start
step 2: get n value
step 3: set initial value i=1, sum=0
Step 4: check i value if(i<=n) goto step 5 else goto step8
step 5: calculate sum=sum+i
step 6: increment i value by 1
step 7: goto step 4
step 8: print sum value
step 9: stop

BEGIN
GET n
INITIALIZE i=1,sum=0
WHILE(i<=n) DO
sum=sum+i
i=i+1
ENDWHILE
PRINT sum
END

Write an algorithm to find factorial of a given number

Step 1: start
step 2: get n value
step 3: set initial value i=1, fact=1
Step 4: check i value if(i<=n) goto step 5 else goto step8
step 5: calculate fact=fact*i
step 6: increment i value by 1
step 7: goto step 4
step 8: print fact value
step 9: stop
BEGIN
GET n
INITIALIZE i=1,fact=1
WHILE(i<=n) DO
fact=fact*i
i=i+1
ENDWHILE
PRINT fact
END

You might also like