Chapter 2- Flowcharts and Algorithms to Solve Problems Short Questions Answer

python short question and answer

Q1- Write an algorithm to sort an array in the descending order.

Ans:- Algorithms to sort an array in descending order-
  1. Begin
  2. Read numbers and store them in an array of n elements, i.e. size of array a is n with elements as a[1], a[2], a[3],...,a[n].
  3. Find the largest element within unsorted array.
  4. Exchange i.e., swap largest value of the array element with that of 1st element, i.e., store it in the 1st element of the unsorted part of array.
  5. Repeat step 3 & 4 until all the elements in the array are arranged in the descending order.
  6. Stop.

Q2- Write an algorithm that reads a year and determines whether it is a leap year or not.

Ans:- Algorithm to determine whether the year is a leap year or not.
  1. Begin
  2. Prompt the user to enter 4 digit year.
  3. Read the year
  4. if (year%100==0 !! year%400==0 !! year%4==0)
        return true(("The year is a leap year")
    else
        return true(("The year is not a leap year")
  1.        5.Stop.

Q3- Write an algorithm to calculate the volume and surface area of sphere, assuming Pi=3.14.

Ans:- Algorithm is given below-
  1. Begin
  2. Read the value of radius (r) of the sphere.
  3. volume = (4*Pi*r*r*r)/3
  4. area=4*Pi*r*r
  5. Print 'volume of sphere', volume
  6. Print 'area of sphere', area
  7. Stop.

Q4- Write an algorithm to calculate area of rectangle. Read the value of length and breadth.

Ans:- Algorithm is given below-
  1. Begin.
  2. Read the value of length (l) and breadth (b) of rectangle.
  3. area=l*b
  4. Print 'Area of Rectangle', area
  5. Stop

Q5- Write an algorithm to calculate simple interest. Read the values of principle amount (p), number of year (n) and rate of interest (r).

Ans:- Algorithm is given below-
  1. Begin
  2. Read the value of principle amount (p), number of year (n) and rate of interest (r).
  3. si=(p*r*n)/100
  4. Print 'Simple Interest is', si
  5. Stop.

Q6- What is flowchart? Explain its different symbols.

Ans- A flowchart is a graphical or symbolic representation of a process. Each step in the process is represented by a different symbol and contains a short description of the process step. The flowchart symbols are linked together with arrows showing the flow of the process. The most common flowchart symbols are as follows-
a) Terminator- An oval-shaped symbol indicates the start or end of the process.
b) Process- A rectangular-shaped symbol indicates all kinds of arithmetic and logical processes.
c) Decision- A diamond-shaped symbol indicates a decision to be made.
d) Connector- A small, labeled, circular symbol is used to indicate a jump in the flowchart.
e) Input/Output- A parallelogram indicates data input or output (I/O) for a process.

Q7- What is an algorithm?

Ans- A set of instructions which describes the steps to be followed to carry out an activity is called an algorithm or procedure for solving a problem.

Q8- Name the symbol used in the flowchart to represent arithmetic and data movement instructions.

Ans- Processing symbol

Q9- Draw a flowchart to print sum of numbers between 1 and the entered number. For example, if you enter 5, then it will find the sum of 1, 2, 3, 4 and 5, i.e., 1+2+3+4+5=15

Ans- Flowchart is given below in figure
  

Figure- Flowchart to print sum of number between 1 and the entered number

Q10- Make a flowchart to solve the following cosine series.

Ans- Flowchart is given below in figure-

flowchart to solve the following cosine series

Figure- Flowchart for cosine series



Post a Comment

0 Comments