Thursday 30 August 2012

Array009

Input a five digit number ( less than 32767 ) and store all the digits of that number in an array.

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

void main ( )
{
            int         md[6], no, c = 0, d =0;
            clrscr ( );
                                        
            printf ("\n\t\t Enter a number......:"); scanf ("%d", & no);
            while ( no > 0 )
            {                             
                              md[c] = no % 10;
                              no = no / 10;
                              c++;
            }                          
                                   
            printf ("\n\n\n\t\t The digits are = ");
            for ( d = c - 1; d >= 0; d-- )
            {                                        
                              printf ("%d ", md[d]);
            }
            getch ( );
}


Click here to contact us

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...