Saturday 1 September 2012

Array014

Input a five digit number and store all the odd digits of that number in an array.

#include <stdio.h>
#include <conio.h>

void main ( )
{
            int           no, md, co = 0, i[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;
                            }
            }                                     
            printf ("\n\n\t Odd Digits are :-");
            for ( md = co-1; md >= 0; md-- )
            {                                                    
                            printf (" %d", i[md] );
            }
            getch ( );
}


Click here to contact us

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...