25-10-2017-lec16-delivered.ppt

  • Uploaded by: Inam Shah
  • 0
  • 0
  • November 2019
  • PDF

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.

More details

  • Words: 39
  • Pages: 2
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

End Display sum

More Documents from "Inam Shah"