1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
//Convert the given integer in to hexaDecimal #include <iostream> using namespace std; void convertToHexa(int num){ char hexaDecimal[100]; int j=0; while(num){ int remainder=num%16; if(remainder<10){ hexaDecimal[j++]=remainder+48; } else{ hexaDecimal[j++]=remainder+55; } num=num/16; } for (int i = j; i >=0 ; i--) { cout<< "HexaDecimal Numbers are :" << hexaDecimal[i]; } cout<<"endl;" } int main() { long int num; cout<<"Enter The Number To Be Conerted"<<endl; cin>>num; convertToHexa(num); return 0; } |
430 total views, 10 views today