pranjal1805

Q8

May 15th, 2021 (edited)
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.41 KB | None | 0 0
  1. #include <stdio.h>
  2. int sum(int x);
  3.  
  4. int main()
  5. {  
  6.     int a;
  7.     printf("bhai number de de plis. UwU \n");
  8.     scanf("%d",&a);
  9.     printf("ye le bhai tera sum ab maze kar: %d\n", sum(a));
  10.    
  11.     return 0;
  12. }
  13.  
  14. int sum(int x)  // 12345 5 45 345 2345 12345
  15. {  
  16.     int k=0;
  17.     k=(x%10)+((x%100)-(x%10))/10+((x%1000)-(x%100))/100+((x%10000)-(x%1000))/1000+((x%100000)-(x%10000))/10000;
  18.     return k;
  19. }
  20.  
Add Comment
Please, Sign In to add comment