C Program to Convert Decimal number into Hexadecimal | Decimal to Hexadecimal Conversion in C | C Language assignment to convert Decimal Number to Hexadecimal
#include
#include
#include
void dec_hex(long int num) // UDF
{
long int rem[50],i=0,length=0;
while(num>0)
{
rem[i]=num%16;
num=num/16;
i++;
length++;
}
printf("\n Hexadecimal number : ");
for(i=length-1;i>=0;i--)
{
switch(rem[i])
{
case 10:
printf("A");
break;
case 11:
printf("B");
break;
case 12:
printf("C");
break;
case 13:
printf("D");
break;
case 14:
printf("E");
break;
case 15:
printf("F");
break;
default :
printf("%ld",rem[i]);
}
}
}
//================================================
void main()
{
long int num;
clrscr();
printf("Enter the decimal number : ");
scanf("%ld",&num);
dec_hex(num); // Calling function
getch();
}
Related Links :
History Of C..
In the beginning was Charles Babbage and his Analytical Engine, a machine
he built in 1822 that could be programmed to carry out different computations.
Move forward more than 100 years, where the U.S. government in
1942 used concepts from Babbage’s engine to create the ENIAC, the first
modern computer.
Meanwhile, over at the AT&T Bell Labs, in 1972 Dennis Ritchie was working
with two languages: B (for Bell) and BCPL (Basic Combined Programming
Language). Inspired by Pascal, Mr. Ritchie developed the C programming
language.
My 1st Program...
#include
#include
void main ()
{
clrscr ();
printf ("\n\n\n\n");
printf ("\t\t\t*******Pankaj *******\n");
printf ("\t\t\t********************************\n");
printf ("\t\t\t\"Life is Good...\"\n");
printf ("\t\t\t********************************");
getch ();
}
Next Step...
#include
#include
void main ()
{
clrscr ();
printf ("\n\n\n\n\n\n\n\n");
printf ("\t\t\t --------------------------- \n\n");
printf ("\t\t\t | IGCT, Info Computers, INDIA | \n\n");
printf ("\t\t\t --------------------------- ");
getch ();
}
No comments:
Post a Comment