I'm pretty new in programming and I making a decimal to binary converter. I need help to make the print output starts from right to left (reversed).(Sorry if my code is messy)
int main()
{
int num, form;
printf("Decimal to Binary\n\n");
printf(" Value : ");
scanf("%d", &num);
printf(" Expected Format (Type 2 for binary): ");
scanf("%d", &form);
if (form == 2)
printf(" %d base 10 is ", num);
if (form == 2)
do {
if (num % 2 == 0) {
printf("0");
num = num / 2;
}
else {
printf("1");
num = num / 2;
}
} while (num > 0);
else
printf("Invalid input!");
return 0;
}
If I input the value to 25,I expected the output will be "11001", but the actual output is "10011"