#include<stdio.h>
char arr[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
void convertNumber(int n, int base)
{
if(n!=0){
int temp = n%base;
convertNumber(n /= base, base);
printf("%c",arr[temp]);
}
}
int main()
{
int n, b;
printf("Enter number to convert : ");
scanf("%d",&n);
printf("Enter base : ");
scanf("%d",&b);
printf("Number in base %d is ",b);
convertNumber(n,b);
return 0;
}
char arr[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
void convertNumber(int n, int base)
{
if(n!=0){
int temp = n%base;
convertNumber(n /= base, base);
printf("%c",arr[temp]);
}
}
int main()
{
int n, b;
printf("Enter number to convert : ");
scanf("%d",&n);
printf("Enter base : ");
scanf("%d",&b);
printf("Number in base %d is ",b);
convertNumber(n,b);
return 0;
}
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন