Hi, i'm really new to programming in C, and iam kind of stuck on this problem, the question is
Write a C function to print out an integer value in base 4 (using only the digits 0, 1, 2, 3). Use this function to write
a program that reads an integer from the keyboard and displays it in base 4 on the screen.
Now i dont understand wat it means by using digits(0, 1, 2, 3), does it mean 00, 01, 02, 03, 10, n so on???
And with regards to the base 4 thing, i knw how to solve it mathematically, heres an example
Using Division
Let's take a number in base 10, like 231 and change it to base 4. First divide 231 by 4
231/4 = 57 with a remainder of 3
Now divide 57 by 4
57/4 = 14 with a remainder of 1
Divide 14 by 4
14/4 = 3 with a remainder of 2
Divide 3 by 4
3/4 = 0 with a remainder of 3
Am i on the rite track with that?
and now finally with regards to the coding side of it, all i really came up with is this...
#include <stdio.h>
int main(){
int number;
printf("Enter a number: ");
scanf("%d", &number);
system("Pause");
return 0;
}
Can some1 plz help me.....