Tom has a homework.His class teacher gave homework in Extract digits from integer in c language.your task is to help tom in extracting it by giving integer number as an input.the output should contain the extracted digits separated by a space. Test Case 1 Input (stdin) 356 Expected Output 3 5 6 Test Case 2 Input (stdin) 4787 Expected Output 4 7 8 7
#include<stdio.h>
int main(){
int num,temp,factor=1;
printf("Enter a number: ");
scanf("%d",&num);
temp=num;
while(temp){
temp=temp/10;
factor = factor*10;
}
printf("Each digits of given number are: ");
while(factor>1){
factor = factor/10;
printf("%d ",num/factor);
num = num % factor;
}
return 0;
}