#include <stdio.h>
int main()
{
int a[20],i,m,n,r;
printf("\n Enter the decimal Integer ");
scanf("%d",&n);
m=n;
for(i=0;n>0;i++)
{
r=n%2;
a[i]=r;
n=n/2;
}
printf("\n Binary equivalent of %d is \t",m);
for(i--;i>=0;i--)
printf("%d",a[i]);
return 0;
}
Enter the decimal Integer 10
Binary equivalent of 10 is 1010
--------------------------------
Process exited after 3.289 seconds with return value 0
Press any key to continue . . .
First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.
Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.