if you entered 2345 then it will show you 5 , 4 , 3 , 2 so for this you have to use the
remainder logic that is just take out the remainder of that number by dividing it from
10 and after that changer the number again by taking quotient of that number by dividing
it from 10 and store that number in n so it will do that until you get all digits.
Program
#include<stdio.h>
#include<conio.h>
void main()
{
int n,rem;
printf("Enter
the number:");
scanf("%d",&n);
while (n>0)
{
rem=n%10;
printf("Digits of number entered by user:%d\n",rem);
n=n/10;
}
Output:
Post a Comment