#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<ctype.h>
#include<math.h>
void func1(int);
void func2(int);
void func3(int);
void func4(int);
void func5(int);
void func6(int);
void func7(char ar[],int);
void func8(char ar[],int);
void func9(char ar[],int);
void func10(int);
void func11(int);
void func12(int);
int a,c,sum=0,i,u,l;
main()
{ int ch,k,g=0;
char cho='Y';
printf("Welcome!!\n\a");
while(toupper(cho)=='Y')
{
printf("\a\nPress->\n\n1:Binary to Decimal\n2:Decimal to Binary\n3:Octal to Decimal\n4:Decimal to Octal\n5:Octal to Binary\n6:Binary to Octal\n7:Hexadecimal to Decimal\n8:Hexadecimal to Binary\n9:Hexadecimal to Octal\n10:Binary to Hexadecimal\n11:Decimal to Hexadecimal\n12:Octal to Hexadecimal\n\n");
printf("You pressed : ");
scanf("%d",&ch);
printf("\a");
switch(ch)
{
case 1:{
printf("Enter Binary Number:");
scanf("%d",&a);
k=a;
while(k!=0)
{
if(k!=0)
{
if((k%10)!=0 && (k%10)!=1)
{
printf("\n\nYou entered a non Binary number!\n\a\a\a");
l=1;
break;
}
k/=10;
}
}
if(l!=1)
{
printf("\a");
func1(a);
}
}
break;
case 2:{
printf("Enter Decimal Number:");
scanf("%d",&a);
printf("\a");
func2(a);
}
break;
case 3:{
printf("Enter Octal Number:");
scanf("%d",&a);
k=a;
while(k!=0)
{
if(k!=0)
{
if((k%10)>7)
{
printf("\n\nYou entered a non Octal number!\n\a\a\a");
break;
}
k/=10;
}
else
{
printf("\a");
func3(a);
}
}
}
break;
case 4:{
printf("Enter Decimal Number:");
scanf("%d",&a);
printf("\a");
func4(a);
}
break;
case 5:{
printf("Enter Octal Number:");
scanf("%d",&a);
k=a;
while(k!=0)
{
if(k!=0)
{
if((k%10)>7)
{
printf("\n\nYou entered a non Octal number!\n\a\a\a");
break;
}
k/=10;
}
else
{
printf("\a");
func5(a);
}
}
}
break;
case 6:{
printf("Enter Binary Number:");
scanf("%d",&a);
k=a;
while(k!=0)
{
if(k!=0)
{
if((k%10)!=0 && (k%10)!=1)
{
printf("\n\nYou entered a non Binary number!\n\a\a\a");
l=1;
break;
}
k/=10;
}
}
if(l!=1)
{
printf("\a");
func6(a);
}
}
break;
case 7:{
char ar[5];
int n=0,j;
printf("Enter Hexadecimal Number:");
printf("\nEnter number of characters in Hexadecimal Number:");
scanf("%d",&n);
printf("\a");
fflush(stdin);
printf("\nEnter Hexadecimal characters separated with spaces:");
for(j=0;j<n;j++)
{
scanf("%s",&ar[j]);
printf("\a");
}
fflush(stdin);
u=-1;
while(ar[++u]!='\0')
{
if(toupper(ar[u])!='A' && toupper(ar[u])!='B' && toupper(ar[u])!='C' && toupper(ar[u])!='D' && toupper(ar[u])!='E' && toupper(ar[u])!='F' && ar[u]!='0' && ar[u]!='1' && ar[u]!='2' && ar[u]!='3' && ar[u]!='4' && ar[u]!='5' && ar[u]!='6' && ar[u]!='7' && ar[u]!='8' && ar[u]!='9')
{
printf("\n\nYou entered a non Hexadecimal number!\nProgram will now EXIT...\a\a\a");
getch();
return 0;
}
}
printf("\a");
func7(ar,n);
}
break;
case 8:{
char ar[5];
int n=0,j;
printf("Enter Hexadecimal Number:");
printf("\nEnter number of characters in Hexadecimal Number:");
scanf("%d",&n);
printf("\a");
printf("\nEnter Hexadecimal characters separated with spaces:");
for(j=0;j<n;j++)
{
scanf("%s",&ar[j]);
}
fflush(stdin);
u=-1;
while(ar[++u]!='\0')
{
if(toupper(ar[u])!='A' && toupper(ar[u])!='B' && toupper(ar[u])!='C' && toupper(ar[u])!='D' && toupper(ar[u])!='E' && toupper(ar[u])!='F' && ar[u]!='0' && ar[u]!='1' && ar[u]!='2' && ar[u]!='3' && ar[u]!='4' && ar[u]!='5' && ar[u]!='6' && ar[u]!='7' && ar[u]!='8' && ar[u]!='9')
{
printf("\n\nYou entered a non Hexadecimal number!\nProgram will now EXIT...\a\a\a");
getch();
return 0;
}
}
printf("\a");
func8(ar,n);
}
break;
case 9:{
char ar[5];
int n=0,j;
printf("Enter Hexadecimal Number:");
printf("\nEnter number of characters in Hexadecimal Number:");
scanf("%d",&n);
printf("\a");
printf("\nEnter Hexadecimal characters separated with spaces:");
for(j=0;j<n;j++)
{
scanf("%s",&ar[j]);
}
u=-1;
while(ar[++u]!='\0')
{
if(toupper(ar[u])!='A' && toupper(ar[u])!='B' && toupper(ar[u])!='C' && toupper(ar[u])!='D' && toupper(ar[u])!='E' && toupper(ar[u])!='F' && ar[u]!='0' && ar[u]!='1' && ar[u]!='2' && ar[u]!='3' && ar[u]!='4' && ar[u]!='5' && ar[u]!='6' && ar[u]!='7' && ar[u]!='8' && ar[u]!='9')
{
printf("\n\nYou entered a non Hexadecimal number!\nProgram will now EXIT...\a\a\a");
getch();
return 0;
}
}
printf("\a");
func9(ar,n);
}
break;
case 10:{
printf("Enter Binary Number:");
scanf("%d",&a);
k=a;
k=a;
while(k!=0)
{
if(k!=0)
{
if((k%10)!=0 && (k%10)!=1)
{
printf("\n\nYou entered a non Binary number!\n\a\a\a");
l=1;
break;
}
k/=10;
}
}
if(l!=1)
{
printf("\a");
func10(a);
}
}
break;
case 11:{
printf("Enter Decimal Number:");
scanf("%d",&a);
printf("\a");
func11(a);
}
break;
case 12:{
printf("Enter Octal Number:");
scanf("%d",&a);
k=a;
while(k!=0)
{
if((k%10)>7)
{
printf("\n\nYou entered a non Octal number!\n\a\a\a");
l++;
break;
}
k/=10;
}
if(l==0)
{
printf("\a");
func12(a);
}
}
break;
default:printf("\nYou Enetred A Wrong Choice!");
}
printf("\n\n\aWant to perform more conversions?(Y/N):");
scanf("%s",&cho);
printf("\a");
system("cls");
}
return 0;
}
void func1(a)
{
while(a!=0)
{
sum+=pow(2,c++)*(a%10);
a/=10;
}
printf("Decimal Equivalent is:%d",sum);
}
void func2(a)
{
int b[15],i,c=0;
printf("Binary Equivalent:");
while(a!=1)
{
b[c++]=a%2;
a/=2;
}
b[c]=1;
for(i=c;i>-1;i--)
printf("%d",b[i]);
}
void func3(a)
{
while(a!=0)
{
sum+=pow(8,c++)*(a%10);
a/=10;
}
printf("Decimal Equivalent is:%d",sum);
}
void func4(a)
{
int b[15],i,c=0;
printf("Octal Equivalent:");
while(a>7)
{
b[c++]=a%8;
a/=8;
}
b[c]=a;
for(i=c;i>-1;i--)
printf("%d",b[i]);
}
void func5(a)
{ int b[15],i;
while(a!=0)
{
sum+=pow(8,c++)*(a%10);
a/=10;
}
func2(sum);
}
void func6(a)
{
while(a!=0)
{
sum+=pow(2,c++)*(a%10);
a/=10;
}
func4(sum);
}
void func7(char ar[],int nr)
{ int i=0,sum=0;
int c=-1;
for(i=nr-1;i>-1;i--)
{c++;
if(toupper(ar[i])=='A')
sum+=pow(16,c)*10;
else if(toupper(ar[i])=='B')
sum=pow(16,c)*11;
else if(toupper(ar[i])=='C')
sum=pow(16,c)*12;
else if(toupper(ar[i])=='D')
sum=pow(16,c)*13;
else if(toupper(ar[i])=='E')
sum=pow(16,c)*14;
else if(toupper(ar[i])=='F')
sum=pow(16,c)*15;
else if(ar[i]=='1')
sum+=pow(16,c)*1;
else if(ar[i]=='2')
sum+=pow(16,c)*2;
else if(ar[i]=='3')
sum+=pow(16,c)*3;
else if(ar[i]=='4')
sum+=pow(16,c)*4;
else if(ar[i]=='5')
sum+=pow(16,c)*5;
else if(ar[i]=='6')
sum+=pow(16,c)*6;
else if(ar[i]=='7')
sum+=pow(16,c)*7;
else if(ar[i]=='8')
sum+=pow(16,c)*8;
else if(ar[i]=='9')
sum+=pow(16,c)*9;
}
printf("Decimal Equivalent is:%d",sum);
}
void func8(char ar[],int nr)
{ int i=0,sum=0;
int c=-1;
for(i=nr-1;i>-1;i--)
{c++;
if(toupper(ar[i])=='A')
sum+=pow(16,c)*10;
else if(toupper(ar[i])=='B')
sum=pow(16,c)*11;
else if(toupper(ar[i])=='C')
sum=pow(16,c)*12;
else if(toupper(ar[i])=='D')
sum=pow(16,c)*13;
else if(toupper(ar[i])=='E')
sum=pow(16,c)*14;
else if(toupper(ar[i])=='F')
sum=pow(16,c)*15;
else if(ar[i]=='1')
sum+=pow(16,c)*1;
else if(ar[i]=='2')
sum+=pow(16,c)*2;
else if(ar[i]=='3')
sum+=pow(16,c)*3;
else if(ar[i]=='4')
sum+=pow(16,c)*4;
else if(ar[i]=='5')
sum+=pow(16,c)*5;
else if(ar[i]=='6')
sum+=pow(16,c)*6;
else if(ar[i]=='7')
sum+=pow(16,c)*7;
else if(ar[i]=='8')
sum+=pow(16,c)*8;
else if(ar[i]=='9')
sum+=pow(16,c)*9;
}
func2(sum);
}
void func9(char ar[],int nr)
{ int i=0,sum=0;
int c=-1;
for(i=nr-1;i>-1;i--)
{c++;
if(toupper(ar[i])=='A')
sum+=pow(16,c)*10;
else if(toupper(ar[i])=='B')
sum=pow(16,c)*11;
else if(toupper(ar[i])=='C')
sum=pow(16,c)*12;
else if(toupper(ar[i])=='D')
sum=pow(16,c)*13;
else if(toupper(ar[i])=='E')
sum=pow(16,c)*14;
else if(toupper(ar[i])=='F')
sum=pow(16,c)*15;
else if(ar[i]=='1')
sum+=pow(16,c)*1;
else if(ar[i]=='2')
sum+=pow(16,c)*2;
else if(ar[i]=='3')
sum+=pow(16,c)*3;
else if(ar[i]=='4')
sum+=pow(16,c)*4;
else if(ar[i]=='5')
sum+=pow(16,c)*5;
else if(ar[i]=='6')
sum+=pow(16,c)*6;
else if(ar[i]=='7')
sum+=pow(16,c)*7;
else if(ar[i]=='8')
sum+=pow(16,c)*8;
else if(ar[i]=='9')
sum+=pow(16,c)*9;
}
func4(sum);
}
void func10(a)
{ char b[10];
int k,i=0,c=0;
while(a!=0)
{
k=a%10000;
if(k==0)
b[i++]='0';
else if(k==1)
b[i++]='1';
else if(k==10)
b[i++]='2';
else if(k==11)
b[i++]='3';
else if(k==100)
b[i++]='4';
else if(k==101)
b[i++]='5';
else if(k==110)
b[i++]='6';
else if(k==111)
b[i++]='7';
else if(k==1000)
b[i++]='8';
else if(k==1001)
b[i++]='9';
else if(k==1010)
b[i++]='A';
else if(k==1011)
b[i++]='B';
else if(k==1100)
b[i++]='C';
else if(k==1101)
b[i++]='D';
else if(k==1110)
b[i++]='E';
else if(k==1111)
b[i++]='F';
a/=10000;
}
printf("Hexadecimal Equivalent:");
for(i=i-1;i>-1;i--)
{
printf("\a");
printf("%c",b[i]);
}
}
void func11(a)
{
int b[15],i,c=0;
while(a!=1)
{
b[c++]=a%2;
a/=2;
}
b[c]=1;
for(i=c;i>-1;i--)
sum=sum*10+b[i];
func10(sum);
}
void func12(a)
{
int b[15],m[15],i,c=0,sum=0,sum1=0;
{
while(a!=0)
{
sum+=pow(8,c++)*(a%10);
a/=10;
}
c=0;
while(sum!=1)
{
m[c++]=sum%2;
sum/=2;
}
m[c]=1;
for(i=c;i>-1;i--)
sum1=(sum1*10)+m[i];
func10(sum1);
}
}
#include<conio.h>
#include<string.h>
#include<ctype.h>
#include<math.h>
void func1(int);
void func2(int);
void func3(int);
void func4(int);
void func5(int);
void func6(int);
void func7(char ar[],int);
void func8(char ar[],int);
void func9(char ar[],int);
void func10(int);
void func11(int);
void func12(int);
int a,c,sum=0,i,u,l;
main()
{ int ch,k,g=0;
char cho='Y';
printf("Welcome!!\n\a");
while(toupper(cho)=='Y')
{
printf("\a\nPress->\n\n1:Binary to Decimal\n2:Decimal to Binary\n3:Octal to Decimal\n4:Decimal to Octal\n5:Octal to Binary\n6:Binary to Octal\n7:Hexadecimal to Decimal\n8:Hexadecimal to Binary\n9:Hexadecimal to Octal\n10:Binary to Hexadecimal\n11:Decimal to Hexadecimal\n12:Octal to Hexadecimal\n\n");
printf("You pressed : ");
scanf("%d",&ch);
printf("\a");
switch(ch)
{
case 1:{
printf("Enter Binary Number:");
scanf("%d",&a);
k=a;
while(k!=0)
{
if(k!=0)
{
if((k%10)!=0 && (k%10)!=1)
{
printf("\n\nYou entered a non Binary number!\n\a\a\a");
l=1;
break;
}
k/=10;
}
}
if(l!=1)
{
printf("\a");
func1(a);
}
}
break;
case 2:{
printf("Enter Decimal Number:");
scanf("%d",&a);
printf("\a");
func2(a);
}
break;
case 3:{
printf("Enter Octal Number:");
scanf("%d",&a);
k=a;
while(k!=0)
{
if(k!=0)
{
if((k%10)>7)
{
printf("\n\nYou entered a non Octal number!\n\a\a\a");
break;
}
k/=10;
}
else
{
printf("\a");
func3(a);
}
}
}
break;
case 4:{
printf("Enter Decimal Number:");
scanf("%d",&a);
printf("\a");
func4(a);
}
break;
case 5:{
printf("Enter Octal Number:");
scanf("%d",&a);
k=a;
while(k!=0)
{
if(k!=0)
{
if((k%10)>7)
{
printf("\n\nYou entered a non Octal number!\n\a\a\a");
break;
}
k/=10;
}
else
{
printf("\a");
func5(a);
}
}
}
break;
case 6:{
printf("Enter Binary Number:");
scanf("%d",&a);
k=a;
while(k!=0)
{
if(k!=0)
{
if((k%10)!=0 && (k%10)!=1)
{
printf("\n\nYou entered a non Binary number!\n\a\a\a");
l=1;
break;
}
k/=10;
}
}
if(l!=1)
{
printf("\a");
func6(a);
}
}
break;
case 7:{
char ar[5];
int n=0,j;
printf("Enter Hexadecimal Number:");
printf("\nEnter number of characters in Hexadecimal Number:");
scanf("%d",&n);
printf("\a");
fflush(stdin);
printf("\nEnter Hexadecimal characters separated with spaces:");
for(j=0;j<n;j++)
{
scanf("%s",&ar[j]);
printf("\a");
}
fflush(stdin);
u=-1;
while(ar[++u]!='\0')
{
if(toupper(ar[u])!='A' && toupper(ar[u])!='B' && toupper(ar[u])!='C' && toupper(ar[u])!='D' && toupper(ar[u])!='E' && toupper(ar[u])!='F' && ar[u]!='0' && ar[u]!='1' && ar[u]!='2' && ar[u]!='3' && ar[u]!='4' && ar[u]!='5' && ar[u]!='6' && ar[u]!='7' && ar[u]!='8' && ar[u]!='9')
{
printf("\n\nYou entered a non Hexadecimal number!\nProgram will now EXIT...\a\a\a");
getch();
return 0;
}
}
printf("\a");
func7(ar,n);
}
break;
case 8:{
char ar[5];
int n=0,j;
printf("Enter Hexadecimal Number:");
printf("\nEnter number of characters in Hexadecimal Number:");
scanf("%d",&n);
printf("\a");
printf("\nEnter Hexadecimal characters separated with spaces:");
for(j=0;j<n;j++)
{
scanf("%s",&ar[j]);
}
fflush(stdin);
u=-1;
while(ar[++u]!='\0')
{
if(toupper(ar[u])!='A' && toupper(ar[u])!='B' && toupper(ar[u])!='C' && toupper(ar[u])!='D' && toupper(ar[u])!='E' && toupper(ar[u])!='F' && ar[u]!='0' && ar[u]!='1' && ar[u]!='2' && ar[u]!='3' && ar[u]!='4' && ar[u]!='5' && ar[u]!='6' && ar[u]!='7' && ar[u]!='8' && ar[u]!='9')
{
printf("\n\nYou entered a non Hexadecimal number!\nProgram will now EXIT...\a\a\a");
getch();
return 0;
}
}
printf("\a");
func8(ar,n);
}
break;
case 9:{
char ar[5];
int n=0,j;
printf("Enter Hexadecimal Number:");
printf("\nEnter number of characters in Hexadecimal Number:");
scanf("%d",&n);
printf("\a");
printf("\nEnter Hexadecimal characters separated with spaces:");
for(j=0;j<n;j++)
{
scanf("%s",&ar[j]);
}
u=-1;
while(ar[++u]!='\0')
{
if(toupper(ar[u])!='A' && toupper(ar[u])!='B' && toupper(ar[u])!='C' && toupper(ar[u])!='D' && toupper(ar[u])!='E' && toupper(ar[u])!='F' && ar[u]!='0' && ar[u]!='1' && ar[u]!='2' && ar[u]!='3' && ar[u]!='4' && ar[u]!='5' && ar[u]!='6' && ar[u]!='7' && ar[u]!='8' && ar[u]!='9')
{
printf("\n\nYou entered a non Hexadecimal number!\nProgram will now EXIT...\a\a\a");
getch();
return 0;
}
}
printf("\a");
func9(ar,n);
}
break;
case 10:{
printf("Enter Binary Number:");
scanf("%d",&a);
k=a;
k=a;
while(k!=0)
{
if(k!=0)
{
if((k%10)!=0 && (k%10)!=1)
{
printf("\n\nYou entered a non Binary number!\n\a\a\a");
l=1;
break;
}
k/=10;
}
}
if(l!=1)
{
printf("\a");
func10(a);
}
}
break;
case 11:{
printf("Enter Decimal Number:");
scanf("%d",&a);
printf("\a");
func11(a);
}
break;
case 12:{
printf("Enter Octal Number:");
scanf("%d",&a);
k=a;
while(k!=0)
{
if((k%10)>7)
{
printf("\n\nYou entered a non Octal number!\n\a\a\a");
l++;
break;
}
k/=10;
}
if(l==0)
{
printf("\a");
func12(a);
}
}
break;
default:printf("\nYou Enetred A Wrong Choice!");
}
printf("\n\n\aWant to perform more conversions?(Y/N):");
scanf("%s",&cho);
printf("\a");
system("cls");
}
return 0;
}
void func1(a)
{
while(a!=0)
{
sum+=pow(2,c++)*(a%10);
a/=10;
}
printf("Decimal Equivalent is:%d",sum);
}
void func2(a)
{
int b[15],i,c=0;
printf("Binary Equivalent:");
while(a!=1)
{
b[c++]=a%2;
a/=2;
}
b[c]=1;
for(i=c;i>-1;i--)
printf("%d",b[i]);
}
void func3(a)
{
while(a!=0)
{
sum+=pow(8,c++)*(a%10);
a/=10;
}
printf("Decimal Equivalent is:%d",sum);
}
void func4(a)
{
int b[15],i,c=0;
printf("Octal Equivalent:");
while(a>7)
{
b[c++]=a%8;
a/=8;
}
b[c]=a;
for(i=c;i>-1;i--)
printf("%d",b[i]);
}
void func5(a)
{ int b[15],i;
while(a!=0)
{
sum+=pow(8,c++)*(a%10);
a/=10;
}
func2(sum);
}
void func6(a)
{
while(a!=0)
{
sum+=pow(2,c++)*(a%10);
a/=10;
}
func4(sum);
}
void func7(char ar[],int nr)
{ int i=0,sum=0;
int c=-1;
for(i=nr-1;i>-1;i--)
{c++;
if(toupper(ar[i])=='A')
sum+=pow(16,c)*10;
else if(toupper(ar[i])=='B')
sum=pow(16,c)*11;
else if(toupper(ar[i])=='C')
sum=pow(16,c)*12;
else if(toupper(ar[i])=='D')
sum=pow(16,c)*13;
else if(toupper(ar[i])=='E')
sum=pow(16,c)*14;
else if(toupper(ar[i])=='F')
sum=pow(16,c)*15;
else if(ar[i]=='1')
sum+=pow(16,c)*1;
else if(ar[i]=='2')
sum+=pow(16,c)*2;
else if(ar[i]=='3')
sum+=pow(16,c)*3;
else if(ar[i]=='4')
sum+=pow(16,c)*4;
else if(ar[i]=='5')
sum+=pow(16,c)*5;
else if(ar[i]=='6')
sum+=pow(16,c)*6;
else if(ar[i]=='7')
sum+=pow(16,c)*7;
else if(ar[i]=='8')
sum+=pow(16,c)*8;
else if(ar[i]=='9')
sum+=pow(16,c)*9;
}
printf("Decimal Equivalent is:%d",sum);
}
void func8(char ar[],int nr)
{ int i=0,sum=0;
int c=-1;
for(i=nr-1;i>-1;i--)
{c++;
if(toupper(ar[i])=='A')
sum+=pow(16,c)*10;
else if(toupper(ar[i])=='B')
sum=pow(16,c)*11;
else if(toupper(ar[i])=='C')
sum=pow(16,c)*12;
else if(toupper(ar[i])=='D')
sum=pow(16,c)*13;
else if(toupper(ar[i])=='E')
sum=pow(16,c)*14;
else if(toupper(ar[i])=='F')
sum=pow(16,c)*15;
else if(ar[i]=='1')
sum+=pow(16,c)*1;
else if(ar[i]=='2')
sum+=pow(16,c)*2;
else if(ar[i]=='3')
sum+=pow(16,c)*3;
else if(ar[i]=='4')
sum+=pow(16,c)*4;
else if(ar[i]=='5')
sum+=pow(16,c)*5;
else if(ar[i]=='6')
sum+=pow(16,c)*6;
else if(ar[i]=='7')
sum+=pow(16,c)*7;
else if(ar[i]=='8')
sum+=pow(16,c)*8;
else if(ar[i]=='9')
sum+=pow(16,c)*9;
}
func2(sum);
}
void func9(char ar[],int nr)
{ int i=0,sum=0;
int c=-1;
for(i=nr-1;i>-1;i--)
{c++;
if(toupper(ar[i])=='A')
sum+=pow(16,c)*10;
else if(toupper(ar[i])=='B')
sum=pow(16,c)*11;
else if(toupper(ar[i])=='C')
sum=pow(16,c)*12;
else if(toupper(ar[i])=='D')
sum=pow(16,c)*13;
else if(toupper(ar[i])=='E')
sum=pow(16,c)*14;
else if(toupper(ar[i])=='F')
sum=pow(16,c)*15;
else if(ar[i]=='1')
sum+=pow(16,c)*1;
else if(ar[i]=='2')
sum+=pow(16,c)*2;
else if(ar[i]=='3')
sum+=pow(16,c)*3;
else if(ar[i]=='4')
sum+=pow(16,c)*4;
else if(ar[i]=='5')
sum+=pow(16,c)*5;
else if(ar[i]=='6')
sum+=pow(16,c)*6;
else if(ar[i]=='7')
sum+=pow(16,c)*7;
else if(ar[i]=='8')
sum+=pow(16,c)*8;
else if(ar[i]=='9')
sum+=pow(16,c)*9;
}
func4(sum);
}
void func10(a)
{ char b[10];
int k,i=0,c=0;
while(a!=0)
{
k=a%10000;
if(k==0)
b[i++]='0';
else if(k==1)
b[i++]='1';
else if(k==10)
b[i++]='2';
else if(k==11)
b[i++]='3';
else if(k==100)
b[i++]='4';
else if(k==101)
b[i++]='5';
else if(k==110)
b[i++]='6';
else if(k==111)
b[i++]='7';
else if(k==1000)
b[i++]='8';
else if(k==1001)
b[i++]='9';
else if(k==1010)
b[i++]='A';
else if(k==1011)
b[i++]='B';
else if(k==1100)
b[i++]='C';
else if(k==1101)
b[i++]='D';
else if(k==1110)
b[i++]='E';
else if(k==1111)
b[i++]='F';
a/=10000;
}
printf("Hexadecimal Equivalent:");
for(i=i-1;i>-1;i--)
{
printf("\a");
printf("%c",b[i]);
}
}
void func11(a)
{
int b[15],i,c=0;
while(a!=1)
{
b[c++]=a%2;
a/=2;
}
b[c]=1;
for(i=c;i>-1;i--)
sum=sum*10+b[i];
func10(sum);
}
void func12(a)
{
int b[15],m[15],i,c=0,sum=0,sum1=0;
{
while(a!=0)
{
sum+=pow(8,c++)*(a%10);
a/=10;
}
c=0;
while(sum!=1)
{
m[c++]=sum%2;
sum/=2;
}
m[c]=1;
for(i=c;i>-1;i--)
sum1=(sum1*10)+m[i];
func10(sum1);
}
}
No comments:
Post a Comment