google-site-verification: googlef8aa845b858144d3.html COMPUTER SCIENCE NOTES: CONVERT ALL INTEGER INTO ANY BASE

Monday, July 17, 2017

CONVERT ALL INTEGER INTO ANY BASE

/*convert all integer into any base */
#include<stdio.h>
#include<conio.h>
void convert(int,int);
void main()
{
int num,base;
clrscr();
printf("Enter a integer :");
scanf("%d",&num);
printf("\nEnter base :");
scanf("%d",&base);
convert(num,base);
getch();
}
void convert(int num, int base)
{
int rem=num%base;
if(num==0)
return ;
convert(num/base ,base);
if(rem<10)
printf("%d",rem);
else
printf("%c",rem-10+'A');
}








No comments:

Post a Comment