You are on page 1of 1

Dietel and Dietel Exercise Solution 2.

53
============================================
#include<iostream>
using std::cout;
using std::cin;
using std::endl;
#include<iomanip>
using std::setbase;
#include<conio.h>
void main()
{
clrscr();
int value;
cout<<"Enter the value ";
cin>>value;
cout<<"\t"<<"decimal\t"<<"\tHex\t"<<"octa"<<"\tbinaray\
t"<<endl;
cout<<"\t"<<setbase(10)<<value<<"\t\t"<<setbase(16)<<
value<<"\t"<<setbase(8)<<value<<"\t";
int rem,temp[10];
rem=value;
for(int i=0;rem!=0;i++)
{
temp[i]=rem%2;
rem=rem/2;
}
cout<<" ";
for(int j=i-1;j>=0;j--)
{
cout<<temp[j];
}
cout<<endl;
getch();
}

http://www.ravianeducation.blogspot.com
FARHAN: 03008855006