Q1- Write an algorithm to sort an array in the descending order.
Ans:- Algorithms to sort an array in descending order-
- Begin
- 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].
- Find the largest element within unsorted array.
- 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.
- Repeat step 3 & 4 until all the elements in the array are arranged in the descending order.
- 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.
- Begin
- Prompt the user to enter 4 digit year.
- Read the year
- if (year%100==0 !! year%400==0 !! year%4==0)
else
return true(("The year is not a leap year")
- 5.Stop.
Q3- Write an algorithm to calculate the volume and surface area of sphere, assuming Pi=3.14.
Ans:- Algorithm is given below-
- Begin
- Read the value of radius (r) of the sphere.
- volume = (4*Pi*r*r*r)/3
- area=4*Pi*r*r
- Print 'volume of sphere', volume
- Print 'area of sphere', area
- Stop.
Q4- Write an algorithm to calculate area of rectangle. Read the value of length and breadth.
Ans:- Algorithm is given below-
- Begin.
- Read the value of length (l) and breadth (b) of rectangle.
- area=l*b
- Print 'Area of Rectangle', area
- 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-
- Begin
- Read the value of principle amount (p), number of year (n) and rate of interest (r).
- si=(p*r*n)/100
- Print 'Simple Interest is', si
- 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
0 Comments