What is Algorithm?

Algorithm

The planned and written step of solving a problem is called an algorithm. As in many businesses, planning is very important when writing a program.

Thanks to our planning, we can prevent the following problems in the future:

  • Defining the problem correctly
  • Finding, testing and developing solutions
  • Determining compatibility with the system
  • Detecting possible errors

Example: The algorithm of the program that finds the sum of two numbers and writes it to the screen;

Start
Enter number, a
Enter number, b
c=a+b
Write on screen, c
End

Example: The algorithm of the program that calculates the area of ​​the rectangle whose side lengths are entered and writes it to the screen (Let's not enter 0 or less side lengths);

Start
Step 1: Enter a short edge of a
Step2: a <= 0, then return to Step 1, if not Step 3 Go to
Step 3: Enter Long-edge, b
Step4: b> 0, go to Step 5, if not Step3 to top
Step 5: Area=a*b
Step6: Write on screen,
Finish

You can review the algorithm examples below.

what is an algorithm, algorithm examples, samples of algorithm, flowchart examples, program drafting

EXERCISES

Algorithm Tutorials
  1. Draw the flowchart of the program that asks the user for 3 written grades for a course, finds the average of these grades, then writes “Failed” if the average is less than 50 and “Passed” if the average is higher.
  2. The algorithm of the program that finds the largest and smallest of 3 numbers entered by the user.
  3. The algorithm that asks the user for the pin code at startup, says "Welcome" if the pin code is entered correctly, requests the code again if it is entered incorrectly, and ends the program by typing "Wrong entry" when the wrong entry is entered for the 3rd time.
  4. Number guessing game: The computer picks a random number between 1 and 1000. The user is asked to guess the number by entering a number. If the user guesses less than the retained number, it gives the message “Up”, if it guesses large, it gives the message “Down”. It continues this process until it guesses correctly. It gives a “Congratulations” message when it guesses correctly. In addition, each time it asks for numbers, it also writes the number of attempts on the screen.
  5. Total Tax: The stationer will enter the price and type of 100 incoming goods. If a computer is entered as a genre, tax will be calculated as 18 percent, and if a book is entered as a genre, tax will be calculated as 8 percent. In this way, the total tax amount for 100 goods will be calculated and written on the screen.
  6. An algorithm that asks the user for numbers 10 times and calculates the sum and average of these numbers and writes them both to the screen.
  7. An algorithm that asks the user for numbers 10 times and counts how many of these numbers are greater than 100 and writes it to the screen.
  8. An algorithm that asks the user for two numbers and writes all the numbers between these numbers to the screen. (hint: the counter starts from number1 and increases up to number2. Each time the counter is written to the screen.)
  9. An algorithm that asks the user for two numbers and prints the even numbers between these numbers on the screen.
  10. An algorithm that asks the user for two numbers and finds the sum of all numbers between these numbers and writes it to the screen.
  11. An algorithm that asks the user for two numbers and finds how many numbers are a multiple of 5 between these numbers.
  12. The algorithm of the program that finds the factorial of the number entered by the user.
  13. The algorithm of the program that asks the user for numbers until 0 is entered from the keyboard and finds the sum of these numbers. (When 0 is entered, the current total will be written to the screen and the program will end)
  14. The algorithm of the program that finds the sum of even numbers between two numbers entered by the user.
  15. The algorithm of the program that finds the largest and smallest of 100 numbers entered by the user.


COMMENTS




Read 512 times.

Online Users: 212



what-is-algorithm