Write an algorithm and DAF to add first 10 natural numbers.
Attachments:
Answers
Answered by
5
Algorithm:
1. Assign a variable to represent the sum.
2. Start a loop within the range of 1 to 11.
3. Add the traversing elements to the variable representing the sum.
4. Print the variable once the loop stops.
A Python program for the same has been given below:
Python has an in-built function called that is used to create user-defined functions. As per the algorithm, we assign a variable 's' to represent the sum and start a loop with the range as (1, 11), since natural numbers start from 1 and the loop always excludes the last element in the range, i.e., 11. We add the traversing elements to the variable 's' and print it.
Equestriadash:
Thanks for the Brainliest! ^_^"
Similar questions