Friday 31 August 2012

Loop control structure068

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

#include <stdio.h>
#include <conio.h>
#include <math.h>
void main ( )
{
          int          md, no, s = 0, d =0;
          clrscr ( );
                                   
          printf ("\n\t\t Enter a octal number......:"); scanf ("%d", & no);
          while ( no > 0 )
          {                                        
                            md = no % 10;
                            no = no / 10;
                            md = md * pow ( 8,d );
                            s = s + md;
                            d++;
          }
                                              
          printf ("\n\n\n\t\t The Decimal number =  %d", s);
          getch ( );
}

Click here to contact us

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...