-->

program to convert decimal number into Hexadecimal.

//program to convert decimal number into Hexadecimal.
#include<stdio.h>
#include<conio.h>
void main()
{
  long int decimal_number;
  printf("Enter any decimal number: ");
  scanf("%ld",&decimal_number);
  printf("Equivalent hexadecimal number is: %X",decimal_number);
getch();
}


logics in mind:

if decimal number is 19 (base 10) then
hexadecimal number can be obtained using simply its format specifier %x.
       note:

we can also write same program using ascii value and array.
the program goes like,
#include<stdio.h>
void main()
{
    long int decimalNumber,remainder,quotient;
    int i=1,j,temp;
    char hexadecimalNumber[100];                    //array is used to store equivalent hexadecimal number
    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;          //48 is added to temp to convert number into character, look ascii table
      else
         temp = temp + 55;                                //ascii value is used as a character after adding to number

      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]);

}

                                        source:
                                         http://www.cquestions.com

program to convert decimal number into binary.

//program to convert decimal number into binary.
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
int k=1,m=0,n,rem,binary=0;
printf("enter decimal value/number of 'n'\n");
scanf("%d",&n);
while(n!=0)
   {
      rem=n%2;
      binary=binary+rem*pow(10,m);
      n=n/2;
      m++;
   }
printf("binary is=%d\n",binary);
getch();
}



logics in mind:

if decimal number is 9 (base 10) then
binary=dividing 9  by 2 and getting remainder.It is 1001. 
making its formula in program
1001=1000+000+00+1
         =1*103+0*102+0*101+1*100
       note:

it does not work for long values(more than 30 04 28). It can, if you declare variables as long.