Computer Science, asked by farzeex, 1 month ago

write an algorithm to find largest of two numbers​

Answers

Answered by anindyaadhikari13
3

\texttt{\textsf{\large{\underline{Answer}:}}}

Algorithm to find the largest of two numbers is given below:

STEP 1: START.

STEP 2: Accept the first number, say A.

STEP 3: Accept the second number, say B.

STEP 4: Check if A > B. If true, display A.

STEP 5: Check if B > A. If true, display B.

STEP 6: Check if A == B. If true, print - "Both are equal."

STEP 7: STOP.

A sample Python program for the same:

a=int(input('Enter first number: '))

b=int(input('Enter second number: '))

if a>b:

   print(a,'is the largest number.')

elif a<b:

   print(b,'is the largest number.')

else:

   print('Both are equal.')

\texttt{\textsf{\large{\underline{Know More}:}}}

Algorithm: An algorithm is defined as a step by step procedure to solve any given problem. It may also be defined as a sequence of instructions to perform a specific task. It is always written in simple language and in precise manner.

Characteristics Of A Good Algorithm:

  1. An algorithm should have 0 or more well defined input.
  2. An algorithm should have 1 or more  well defined output. It algorithm must product a result.
  3. It must be clear and precise.
  4. It should be independent of any programming language.
  5. It must terminate after a finite number of steps.
  6. An algorithm should be feasible with the available resources and so on.
Similar questions