Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- unsigned sumDigits(unsigned n){
- unsigned sum=0;
- while(n){
- sum+=n%10;
- n=n/10;
- }
- return sum;
- }
- int main(){
- unsigned n;
- printf("Kerem a szamot: ");
- scanf("%u",&n);
- printf("A szamjegyek osszege %u.\n",sumDigits(n));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment