Code: clear clc n = input('Enter the n value : \n'); s = 0; while n>0 s = s + mod(n,10); n = floor(n/10); end fprintf('Sum of digit : %d\n',s); Output:
Leave a Comment