i have doubt in this challenge that we have to take all the inputs at a single time and then output in their respectively lines or we have to take one input then show output again take input upto n numbers
Binary to decimal
its upto you can take all the input at single time and then solve for each of them and store the output and then ouput it all but usually we take one input solve for it print solution and then take another input.
Code which takes one input and solves for it and then takes another input
ok i got it another thing that i wanna ask, that is there any other way of storing all the decimals other than array? i have not yet reach that topic yet.
you can also use vector which a dynamic array
#include
#include<math.h>
using namespace std;
int main()
{
int n,sum=0;
int m;
long long no;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>no;
int l=0;
while(no!=0)
{
m=n%10;
no=no/10;
sum+=m*pow(2,l);
l++;
}
cout<<sum;
}
return 0;
}
i asked the error in whatsapp group but they told me to ask the query here. Its not showing the desire output in sublime and your platform as well.
corrected code with comments
hey can you tell what’s my score in binary to decimal problem?
I dont think i can tell you that but if you visit the question on hacker blocks you should be able to see it.