Friday 31 August 2012

Array011

Input a decimal number  and print the octal equivalent of that number.

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

void main ( )
{
             int       md[10], no, s = 0, d =0;
             clrscr ( );
                                       
             printf ("\n\t\t Enter a decimal number......:"); scanf ("%d", & no);
             while ( no > 0 )
             {                                  
                               md[s] = no % 8;
                               no = no / 8;
                               s++;
             }
                                                     
             printf ("\n\n\n\t\t The Octal number =  ");
             for ( d = s - 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...