Sum of Digits of a Five Digit Number Discussions | C | HackerRank
We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
#include<stdio.h>intmain(){intn;scanf("%d",&n);// Calculate the sum of the digitsintsum=0;while(n>0){sum+=n%10;// Add the last digit to the sumn/=10;// Remove the last digit}printf("%d\n",sum);return0;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Sum of Digits of a Five Digit Number
You are viewing a single comment's thread. Return to all comments →