#include<iostream>
#include<string.h>
using namespace std;
int main()
{
int a, b[100] = {0}, i, j, l;
char ch[100];
cout << "Enter Decimal Number : ";
cin >> a;
cout << endl;
i = 0;
while(a != 0)
{
b[i] = a%16;
a = a/16;
i++;
}
for(j=i-1, l = 0;j>=0;j--, l++)
{
if(b[j] >= 0 && b[j] <= 9)
{
ch[l] = b[j] + 48;
}
else if(b[j] >=10 && b[j] <= 15)
{
ch[l] = b[j] + 55;
}
}
ch[l] = '\0';
cout << "Hexadecimal Number :: " << ch << endl;
return 0;
}
#include<string.h>
using namespace std;
int main()
{
int a, b[100] = {0}, i, j, l;
char ch[100];
cout << "Enter Decimal Number : ";
cin >> a;
cout << endl;
i = 0;
while(a != 0)
{
b[i] = a%16;
a = a/16;
i++;
}
for(j=i-1, l = 0;j>=0;j--, l++)
{
if(b[j] >= 0 && b[j] <= 9)
{
ch[l] = b[j] + 48;
}
else if(b[j] >=10 && b[j] <= 15)
{
ch[l] = b[j] + 55;
}
}
ch[l] = '\0';
cout << "Hexadecimal Number :: " << ch << endl;
return 0;
}
Comments
Post a Comment