Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Let n be a integer consisting of up to 10 digits d10, d9, d8.....d1. Write a pro

ID: 3642832 • Letter: L

Question

Let n be a integer consisting of up to 10 digits d10, d9, d8.....d1. Write a program to list in one of the column each of the digits in the number n. The right most digits is d1, should be listed at the top of column. (enter 456, it should show 6, 5, 4)
Hint : If n is 3704 what is the value of digit when computed by using digit = n % 10

here's the codes: when I run the positive numbers, it works fine. However when I run the negative number, it shows errors. For example: when i enter -450, it shows 0, -5, -4.

#include <stdio.h>

int main(void){

int n, d;
printf("Enter an integer: ");
scanf("%d",&n);
while(n > 0 || n < 0);
{
d=n%10;
n=n/10;
printf("%d ",d);
}
printf(" That's All. Have a nice day!");

return(0);
}

Thank you!

Explanation / Answer

#include #include int main(void){ int n, d; printf("Enter an integer: "); scanf("%d",&n); if(n 0) { d = n % 10; n -= d; n/=10; printf("%d ", d); } printf(" That's All. Have a nice day!"); return(0); }