# Decimal to Binary

Logic for the program is shown in the image below. This logic you might have learned during your school days.

Steps:

- We continuously divide the given number by 2.
- Store the remainder.
- And print them in reverse order.

#include<stdio.h> int main(){ int n; printf("Enter Number in decimal\n"); scanf("%d",&n); int arr[32]; int index=0; while(n!=0){ arr[index]=n%2;//Store the remainder index++; n=n/2; } int i; printf("Binary Form is "); for(i=0;i<index;i++){ printf("%d",arr[i]);//Print the remainder to get binary form } return 0; }

I think you will be helpful for those students who want to learn c. Thanks sir

binary to decimal please ……..