Von nueman loves binary problem

please check my code i am not able to get any output and give me correct solution
#include
using namespace std;

int main() {
int N ;

cin>>N;
while(N==0){


int num ;
cin>>num;
int dec_value = 0; 

// Initializing base value to 1, i.e 2^0 
int base = 1; 

int temp = num; 
while (temp) { 
    int last_digit = temp % 10; 
    temp = temp / 10; 

    dec_value += last_digit * base; 

    base = base * 2; 
} 

cout<<dec_value;

N=N-1;

}
return 0;
}

Hi @Basant-Kumar-1342173592623612
You should use while(N!=0)

Hope this helps
Mark resolved if satisfied :slight_smile:

1 Like