![]() The following are the factors that we need to consider for designing an algorithm: Step 4: Add the values of a and b and store the result in the sum variable, i.e., sum=a+b. Step 2: Declare three variables a, b, and sum. The following are the steps required to add two numbers entered by the user: We will write an algorithm to add two numbers entered by the user. Now we will look an example of an algorithm in programming. An algorithm also says that each and every instruction should be followed in a specific order to perform a specific task. ![]() We cannot perform the step 3 before the step 2, we need to follow the specific order to make lemon juice. The above real-world can be directly compared to the definition of the algorithm. Step 6: Store the juice in a fridge for 5 to minutes. Step 5: When sugar gets dissolved, add some water and ice in it. Step 4: Stir the container until the sugar gets dissolved. Step 2: Squeeze the lemon as much you can and take out its juice in a container. Step 1: First, we will cut the lemon into half. Suppose we want to make a lemon juice, so following are the steps required to make a lemon juice: Let's understand the algorithm through a real-world example. If the problem can be easily broken into smaller steps means that the problem is feasible.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |