Here i am not able to take input and output as question asks

#include

using namespace std;
int bintodec(int nos){
int base = 1;
int decval =0;
while(nos){
int lastdig = nos%10;
nos=nos/10;
decval+= lastdigbase;
base
=2;
}
return decval;

}
int main(){
int N,nos;
cin>>N;
for (int i = 1;i<=N;i++){
cin>>nos;

cout<<bintodec(nos);

 
}  

}

hi @dipamagarwal7448, code is correct you r missing newline after each test case
so just write cout<<bintodec(nos)<<endl;

actually i am not able to take n inputs directly and then printing the result. in my code as i input any binary number , rather than takin other input on the next line , my code returns the output first . but ATQ it must take n inputs first and then n outputs must get printed

@dipamagarwal7448, it’s same thing don’t worry and this one is better where u r not using any extra space to store