Computer Science, asked by manisha1774, 11 months ago

Write a 'c' program to arrange the even digits first and odd digits second of the given number

Answers

Answered by sswaraj04
0

Answer:

#include <stdio.h>

#include<math.h>

int main()

{

   int n;

   printf("Enter the number");

   scanf("%d",&n);

   int count=0;                               //to count no. of odd digit to add them finally

   int even=0,odd=0;                          //storing odd digits and even digits seperately

   while(n>0)

   {

       int x=n%10;

       if(x%2==0)

       {

           even=even*10+x;

       }

       else

       {

           odd=odd*10+x;

           count++;

       }

       n/=10;

   }

   int num=even*pow(10,count)+odd;                   //now adding odd digit at last

   

   printf("%d",num);

   return 0;

}

Explanation:

Hope it helps :-)

Similar questions