I'm new to C and I'm trying to convert decimal to binary. The result is giving me an inverse number of what's required. I tried to apply modulo on the result like I saw on other forums but I still get the same result. Any help?
#include<stdio.h>
int main()
{
int number;
long int quotient, rem, result=0;
printf("Enter a number: ");
scanf("%d", &number);
quotient=number;
while (quotient!=0)
{
quotient=quotient/2;
rem=quotient%2;
rem = rem%10;
printf("%ld", rem);
}
}