Input a five digit number and store all the odd and even digits of that number in two different array.
#include <stdio.h>
#include <conio.h>
void main ( )
{
int no, md, co = 0, so = 0, i[5], j[5];
clrscr ( );
printf ("\n\t Enter a number (less than 32767)...........:"); scanf ("%d", &no);
while ( no > 0 )
{
md = no % 10;
no = no / 10;
if ( md % 2 != 0 )
{
i[co++] = md;
}
else
{
j[so++] = md;
}
}
printf ("\n\n\t Odd Digits are :-");
for ( md = co - 1; md >= 0; md-- )
{
printf (" %d", i[md] );
}
printf ("\n\n\t Even Digits are :-");
for ( md = so - 1; md >= 0; md-- )
{
printf (" %d", j[md] );
}
getch ( );
}
Click here to contact us
No comments:
Post a Comment