Removing all Zero from a given number

Problem Statement
write a  c program which
scans a number and then removes all zeroes in it, such that relative order remains same and prints the resulting number. Thus, if the input number
is 94032000051, then the transformed number should be 943251.
#include<stdio.h>
void remo_all_zero(long int n);
int main()
{
  long int n;
  printf("enter the number \n");
  scanf("%ld",&n);
  printf("%ld \n",n);
  remo_all_zero(n);
  printf("\n");
  return 0;
}
void remo_all_zero(long int n)
{
  int a[10],temp,counter,i;
  counter=0;
  do{
    temp=n%10;
    if(temp!=0)
      {
a[counter]=temp;
counter++;
      }
    n=n/10;
  }
  while(n>0);
  for(i=counter-1;i>=0;i--)
    {
      printf("%d",a[i]);
    }
  return ;
}

1 comment: