How to write a program to convert a binary number to a decimal number?

#include <stdio.h> int main() {     int num, rem, digit=0, j=1;          printf(“Enter the number in binary \n”);     scanf(“%d”, &num);          while(num > 0){         rem = num%10;         digit += rem*j;         j *= 2;         num = num/10;     }          […]