Friday, September 21, 2018

Introduction-Algorithm

Algorithm is concise list of steps in english language in short sentences required in solving a problem.

Eg:

1. Check if a given number is even or odd

Algorithm :

1.Start
2. Accept the number.
3.Divide the number by 2
4.If the remainder of the division is zero,then the number is even.
5.Otherwise the number is odd.
6. End

2.Name the fruit.

Algorithm:

1. Start
2.Accept the character.
3.Print"enter alphabet a,b or c"
4. If a is entered,print apple.
5If b is entered ,print banana.
6. If c is entered,print cane.
7.End

3.Tell whether it is a leap year or not.

Algorithm:

1.Start.
2.Accept the year.
3.Print"enter any year.If n mod (%)4==0 or n%400==0) where n is the year.
4.Print "Leap year"
5.Otherwise,print "year is not a leap year.".
6.End



No comments:

Post a Comment