C Program For separating Digits from Number

Program Code:

#include<stdio.h>
int main()
{
int number ,a[5] ,i , temp , j;
printf("Enter any 5 digit number :  ");
scanf("%d",&number);

for(i =0;i<5;i++)
{
temp = number % 10;
a[i] = temp ;
number = number / 10 ;
}

printf("Digits are :  %d , %d , %d , %d , %d \n" ,a[4] ,a[3] ,a[2],a[1],a[0]);

return 0;
}

Output:

.exe file

No comments:

Post a Comment

Please disable your ad blocker to support this website.

Our website relies on revenue from ads to keep providing free content.