#include <stdio.h> #include <math.h> int main(void){ int n, d; printf(\"Enter an
ID: 3642970 • Letter: #
Question
#include <stdio.h>#include <math.h>
int main(void){
int n, d;
printf("Enter an integer > %d ",n);
while(n > 0)
{
n=n/10;
d=n%10;
printf("%d ",d);
}
while (n < 0)
{
n=-n;
d=n%10;
n=n/10;
}
return(0);
}
Question: Let n be a positive integer consisting of digits upto 10 digits d10d9d8d7d6d5d4d3d2d1. Write a program to list in one column each of the digits in the number n. The right most digit, d1, should be first entry printed. Hint: If n is 3708, what is the value of the expression n % 10?" Make sure it works like the oracle for pos & neg integers.
Thanks in advance!
Explanation / Answer
#include #include int main(void){ int n, d; printf("Enter an integer >"); scanf("%d",&n); if(n=10) { d=n%10; n=n/10; printf("%d ",d); } printf("-%d",n); return 0;; } if(n==0) printf("0"); if(n>0) { while(n!=0) { d=n%10; n=n/10; printf("%d ",d); } } return(0); }Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.