Given an interger,
1) Count its digits
2) Output its every digit seperately
3) Output this integer in reverse order
Hint: Use character string to store the input interger
#include<stdio.h>
int main()
{
char str[100];
int i, count = 0;
printf("Please input an integer:\n");
scanf("%s",str);
for (i = 0; str[i]!='\0'; i++)
{
count++;
printf("%c\n",str[i]);
}
for (i = count; i >= 0; i--)
{
printf("%c",str[i]);
}
printf("\nThe digits of this integer is %d\n",count);
return 0;
}
Input:
Please input an interger:
5543654
Output:
5
5
4
3
6
5
4
4563455
The digits of this integer is 7