1. Question:Decimal to binary conversion in c programming language. 

    Answer
    #include<stdio.h>
    
    int main(){
    
        long int decimalNumber,remainder,quotient;
    
        int binaryNumber[100],i=1,j;
    
        printf("Enter any decimal number: ");
    
        scanf("%ld",&decimalNumber);
    
        quotient = decimalNumber;
    
        while(quotient!=0){
    
             binaryNumber[i++]= quotient % 2;
    
             quotient = quotient / 2;
        }
    
        printf("Equivalent binary value of decimal number %d: ",decimalNumber);
    
        for(j = i -1 ;j> 0;j--)
    
             printf("%d",binaryNumber[j]);
    
        return 0;
    }
    Sample output: Enter any decimal number: 50 Equivalent binary value of decimal number 50: 110010






    1. Report
  2. Question:C code for decimal to octal converter 

    Answer
    #include<stdio.h>
    
    int main(){
    
      long int decimalNumber,remainder,quotient;
      int octalNumber[100],i=1,j;
    
      printf("Enter any decimal number: ");
      scanf("%ld",&decimalNumber);
    
      quotient = decimalNumber;
    
      while(quotient!=0){
          octalNumber[i++]= quotient % 8;
          quotient = quotient / 8;
      }
    
      printf("Equivalent octal value of decimal number %d: ",decimalNumber);
      for(j = i -1 ;j> 0;j--)
          printf("%d",octalNumber[j]);
    
      return 0;
    }
    Sample output: Enter any decimal number: 50 Equivalent octal value of decimal number 50: 62






    1. Report
  3. Question:Easy way to convert decimal number to octal number in c 

    Answer
    #include<stdio.h>
    int main(){
    
      long int decimalNumber;
    
      printf("Enter any decimal number : ");
      scanf("%d",&decimalNumber);
    
      printf("Equivalent octal number is: %o",decimalNumber);
    
      return 0;
    }
    Sample output: Enter any decimal number: 25 Equivalent octal number is: 31






    1. Report
  4. Question:C code to convert decimal to hexadecimal 

    Answer
    #include<stdio.h>
    int main(){
        long int decimalNumber,remainder,quotient;
        int i=1,j,temp;
        char hexadecimalNumber[100];
    
        printf("Enter any decimal number: ");
        scanf("%ld",&decimalNumber);
    
        quotient = decimalNumber;
    
        while(quotient!=0){
             temp = quotient % 16;
    
          //To convert integer into character
          if( temp < 10)
               temp =temp + 48;
          else
             temp = temp + 55;
    
          hexadecimalNumber[i++]= temp;
          quotient = quotient / 16;
      }
    
        printf("Equivalent hexadecimal value of decimal number %d: ",decimalNumber);
        for(j = i -1 ;j> 0;j--)
          printf("%c",hexadecimalNumber[j]);
    
        return 0;
    }
    Sample output: Enter any decimal number: 45 Equivalent hexadecimal value of decimal number 45: 2D






    1. Report
  5. Question:Easy way to convert decimal number to hexadecimal number 

    Answer
    #include<stdio.h>
    int main(){
    
      long int decimalNumber;
    
      printf("Enter any decimal number: ");
      scanf("%d",&decimalNumber);
    
      printf("Equivalent hexadecimal number is: %X",decimalNumber);
    
      return 0;
    }
    Sample output: Enter any decimal number: 45 Equivalent hexadecimal number is: 2D






    1. Report
Copyright © 2025. Powered by Intellect Software Ltd