This document was uploaded by user and they confirmed that they have the permission to share
it. If you are author or own the copyright of this book, please report to us by using this DMCA
report form. Report DMCA
Overview
Download & View 25-10-2017-lec16-delivered.ppt as PDF for free.
Exercise 1 If a five-digit number is input through the keyboard, write an algorithm to calculate the sum of its digits. (Hint: Use the modulus operator ‘%’)
Solution Input n Repeat until n>0 x=n%10 sum=sum+x n=n/10