#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
char a[20];
cin>>a;
int len=strlen(a);
ll ans=0ll;
ans=(1<<len)-2;
for(int i=len-1,pos=0;i>=0;i–,pos++)
{
if(a[i] == ‘7’)
{
ans +=(1<<pos);
}
}
cout<<ans+(1<<0)<<endl;
return 0;
}
Sir when i print (ans+1) why it give segmentation fault.
but succesfully run when printing (ans+(1<<0))
Sir please explain me reason for this
why this happen.