Documente Academic
Documente Profesional
Documente Cultură
#include<stdio.h>
#include<iomanip>
int main()
return 0;
system("pause");
int dectooct(int a)
cin>>decnum;
quot=decnum;
while(quot!=0)
octnum[i++]=quot%8;
quot=quot/8;
cout<<octnum[j];
int dectohexa(int)
long dec;
int rem;
std::cout << "enter decimal number: ";
if (rem > 9) {
switch (rem) {
else {
return rem;
}
void Dec_To_Hex(unsigned int dec)
char hex[8];
while (dec>=1)
c=10;c2=0;
if ((dec%16)<10)
while (c2!=dec%16)
c2++;
hex[c3]=number[c2];
}
c2=0;
if ((dec%16)>=10)
while (dec%16!=c)
hex[c3]=letter[c2];
dec/=16;
c3++; // going on to next position in the array for the output of hex conversion
while (c3>=0)
if (c3<=0)
goto end;
c3--;
cout<<hex[c3];
end:
}
int octal_sum(int a,int b) //a and b and octal numbers
int sum=0,carry=0,d=0;
while(a||b||carry)
d=0;
d=carry+(a%10)+(b%10);
a/=10;b/=10;
if(d>7)
carry=1;
d=d%8;
else {
carry = 0;
sum += d*m;
m *= 10;
}
#include<iostream>
#include<stdio.h>
#include<iomanip>
int dectooct(int);
int main()
int octnum1,octnum2;
cin>>decnum1;
cin>>decnum2;
octnum1=dectooct(decnum1);
octnum2=dectooct(decnum2);
return 0;
system("pause");
int dectooct(int a)
{
cin>>decnum;
quot=decnum;
while(quot!=0)
octnum[i++]=quot%8;
quot=quot/8;
cout<<octnum[j];
return octnum;
}
#include <iostream>
#include <string>
int main()
string abc ;
if(abc.empty())
string abc1;
cout<<"abc1 = "<<abc1<<endl;
cout<<"abc2 = "<<abc2<<endl;;
cout<<"abc3 = "<<abc3<<endl;
cout<<"abc4 = "<<abc4<<endl;
cout<<"abc5 = "<<abc5<<endl;
return 0;
}
#include<iostream>
#include<stdio.h>
#include<iomanip>
int main()
int octnum1,octnum2;
cin>>decnum1;
cin>>decnum2;
dectooct(decnum1,decnum2);
dectohexa(decnum1,decnum2);
return 0;
system("pause");
decnum[0]=a;
decnum[1]=b;
for(int k=0;k<2;k++)
{
quot=decnum[k];
while(quot!=0)
octnum[i++]=quot%8;
quot=quot/8;
cout<<octnum[j];
cout<<endl;
long decnum[2];
decnum[0]=decnum1;
decnum[1]=decnum2;
int rem;
for(int k=0;k<2;k++)
{
if (rem > 9)
switch (rem)
else
cout<<endl;
}
}
#include<iostream>
#include<stdio.h>
#include<iomanip>
int main()
int octnum1,octnum2;
cin>>decnum1;
cin>>decnum2;
dectooct(decnum1,decnum2);
dectohexa(decnum1,decnum2);
return 0;
system("pause");
decnum[0]=a;
decnum[1]=b;
int c=0;
int octnum[2][100];
for(int k=0;k<2;k++)
int i=1, j;
quot=decnum[k];
while(quot!=0)
cout<<i<<endl;
octnum[c][i++]=quot%8;
cout<<i<<endl;
quot=quot/8;
cout<<octnum[c][j];
cout<<endl;
{
long decnum[2];
decnum[0]=decnum1;
decnum[1]=decnum2;
int rem;
for(int k=0;k<2;k++)
if (rem > 9)
switch (rem)
else
{
cout << rem;
cout<<endl;
}
long int decnum, rem, quot;
char hexdecnum[100];
int i=1, j, temp;
quot=decnum;
while(quot!=0)
{
temp=quot%16;
// to convert integer into character
if(temp<10)
{
temp=temp+48;
}
else
{
temp=temp+55;
}
hexdecnum[i++]=temp;
quot=quot/16;
}
cout<<"Equivalent hexadecimal value of "<<decnum<<" is : \n";
for(j=i-1; j>0; j--)
{
cout<<hexdecnum[j];
}
getch();
}
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<iomanip>
#include<math.h>
#include<cmath>
#include<conio.h>
int main()
int octnum1,octnum2;
cin>>decnum1;
cin>>decnum2;
dectooct(decnum1,decnum2);
dectohexa(decnum1,decnum2);
return 0;
system("pause");
}
void dectooct(int a,int b)
decnum[0]=a;
decnum[1]=b;
sumnum[d]={0};
int octnum[2][100]={0};
for(int k=0;k<2;k++)
int i=1, j;
quot=decnum[k];
while(quot!=0)
octnum[c][i++]=quot%8;
quot=quot/8;
for(j=i-1;j>0;j--)
product=pow(p,j-1);
sumnum[d]=sumnum[d]+octnum[c][j]*product;
cout<<sumnum[d]<<endl;
c=c+1;
d=d+1;
octalsum(sumnum, 2);
decnum[0]=decnum1;
decnum[1]=decnum2;
char hexdecnum[100];
int b=0,sum=0;
for(int a=0;a<2;a++)
quot=decnum[a];
while(quot!=0)
temp=quot%16;
if(temp<10)
temp=temp+48;
else
{
temp=temp+55;
hexdecnum[i++]=temp;
quot=quot/16;
hexdecnum[i]={'\o'};
cout<<hexdecnum[j];
cout<<endl;
sumnum[a]=convtodecnum(hexdecnum,i-1);
cout<<"a"<<sumnum[a]<<endl;
sum=sum+sumnum[a];
char *hexstr;
int length = 0;
const int base = 16;
int i;
length++;
cout<<length<<endl;
hexstr = hexdecnum;
else if ((*hexstr >= 65 && *hexstr <= 70)) // is *hexstr Between A-F
else if (*hexstr >= 97 && *hexstr <= 102) // is *hexstr Between a-f
{
decnum += (((int)(*hexstr)) - 87) * pow(base, length - i - 1);
else
return decnum;
hexstr = hexdecnum;
else if ((*hexstr >= 65 && *hexstr <= 70)) // is *hexstr Between A-F
else if (*hexstr >= 97 && *hexstr <= 102) // is *hexstr Between a-f
{
else
cout<<"check"<<decnum<<endl;
return decnum;
void octalsum(int sumnum[], int size ) //a and b and octal numbers
int a=sumnum[0];
int b=sumnum[1];
int sum=0,carry=0,d=0,m=1;
while(a||b||carry)
d=0;
d=carry+(a%10)+(b%10);
a/=10;b/=10;
if(d>7)
carry=1;
d=d%8;
else
carry = 0;
sum += d*m;
m *= 10;