Write a program that prompt the user to input a four digit positive interger. The program then output the digit of the number, one digit per line. For example, if the input is 3245, the is
3
2
4
5
Thanks...
#include <stdio.h>
int main()
{
int n;
printf("\nEnter an integer: ");
scanf("%d",&n);
//int n=3245;
int x1=n/1000;
printf("%d\n",x1);
n=n-(x1*1000);
int x2=n/100;
printf("%d\n",x2);
n=n-(x2*100);
int x3=n/10;
printf("%d\n",x3);
n=n-(x3*10);
printf("%d\n",n);
return 0;
}
Comments
Leave a comment