AedenCak3

SP. question 3

Dec 2nd, 2021
737
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<stdio.h>
  2. int get_num(){
  3. printf("Enter an Integer:");
  4. int n;
  5.  
  6. scanf("%d",&n);
  7.  
  8. while(n<1 || n>999999){
  9. printf("Enter between(1-999999):");
  10. scanf("%d",&n);
  11. }
  12. return n;
  13. }
  14. void input(int val){
  15.  
  16. int sum = 0;
  17.  
  18. int n = val;
  19.  
  20. while(n>0){
  21.  
  22. printf("%d\n",n%10);
  23. sum += n%10;
  24.  
  25. n/=10;
  26. }
  27.  
  28. if(sum%9==0){
  29. printf("%d is divisible by 9\n",val);
  30. }
  31. else{
  32. printf("%d is not divisible by 9\n",val);
  33. }
  34. }
  35. int main(){
  36. int val = get_num();
  37. input(val);
  38. return 0;
  39. }
  40.  
RAW Paste Data