Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int loopnum(int n);
- int
- main(void)
- {
- int num;
- int sum = 0;
- int d = loopnum(num);
- printf("Enter a number:n");
- scanf("%d", &num);
- while(loopnum(num) > 0)
- {
- printf("d = %d", d);
- printf(",sum = %dn",sum);
- }
- if(num % 9 == 0)
- {
- printf("n = %d is divisible by 9n", num);
- }
- else
- {
- printf("n = %d is not divisible by 9n", num);
- }
- return 0;
- }
- int
- loopnum(int n)
- {
- n = n % 10;
- n = n / 10;
- return n;
- }
- Enter a number:
- 9
- n = 9 is divisible by 9
- The result of this code is suppose to output d = "the digit" ,sum =
- "digit + sum" and n = "digit" is divisible by 9. for example if I
- input 9. The output would be d = 9, sum = 9.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement