C Program To Conversion of Decimal number into other bases

ALGORITHM: 

    1. Start 

    2. Declare variables. 

    3. Read a decimal number. 

    4. Develop the procedure for conversion of different base by modulus and divide operator. 

    5. Display the output of the conversion value. 

    6. Stop

PROGRAM:

#include<stdio.h>    
#include<stdlib.h>  
int main(){  
int a[10],n,i;    
system ("cls");  
printf("Enter the number to convert: ");    
scanf("%d",&n);    
for(i=0;n>0;i++)    
{    
a[i]=n%2;    
n=n/2;    
}    
printf("\nBinary of Given Number is=");    
for(i=i-1;i>=0;i--)    
{    
printf("%d",a[i]);    
}    
return 0;  
} 
 
Output:
Enter the number to convert: 555
Binary of Given Number is=1000101011

Leave a comment