Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h> //program to convert base
- main()
- {
- char digits[16]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
- int store[64];
- int i=0,base,n,no;
- printf("Enter your number: ");
- scanf("%d",&n);
- printf("Enter your base: ");
- scanf("%d",&base);
- do
- {
- store[i]=n%base;
- i++;
- n/=base;
- } while (n);
- //the problem is everytime i becomes "-1", when it should have become "i-1"
- for(--i;i>=0;i--);
- {
- printf("%c",digits[store[i]]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement