Count Number of Binary srtings

Why my code is not working, I use 2-D do approach to solve it kindly go through my code and resolve it

int main() {

int t;
cin>>t;
while(t--){
	int n;
	cin>>n;
	int dp[n+1][2];
	dp[1][0]=1;
	dp[1][1]=1;
	if(n==1)
	  cout<<dp[1][1]+dp[1][0]<<endl;
	for(int i=2;i<=n;i++){
		dp[i][0]=(dp[i-1][0]+dp[i-1][1]);
		dp[i][1]=(dp[i-1][0]);
	}

	cout<<(dp[n][1]+dp[n][0])<<endl;
}

}

#include

using namespace std;

long long int printConsq1s(int n){

long long int dp[n];

dp[0] = 2;

dp[1] = 3;

for(int i=2;i<n;i++){

    dp[i] = dp[i-1] + dp[i-2];

}

return dp[n-1];

}

int main() {

int t;

cin>>t;

while(t--){

    int n;

    cin>>n;

    cout<<printConsq1s(n)<<endl;

}

return 0;

}

refer this

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.