Language: C++

#include <stdio.h>



#define MOD 1000000007
typedef long long int ll;

//dp solution
ll grid1_dp( ll H, ll W, ll cols, char arr[][cols]){

	ll dp[H][W];
	
	for(int h=0;h<H;h++){
		for(int w=0;w<W; w++){
		
			if(h<0||w<0) dp[h][w]=0;

			else if(h==0 && w==1 && arr[h][w]=='.')
				dp[h][w]=1;
			else if(h==0 && w==1 && arr[h][w]=='#')
				dp[h][w]=0;
				
			else if(h==1 && w==0 && arr[h][w]=='.')
				dp[h][w]=1;
				
			else if(h==1 && w==0 && arr[h][w]=='#')
				dp[h][w]=0;
				
			else if(arr[h-1][w]=='.' && arr[h][w-1]=='.' && h-1>=0 && w-1>=0)
				dp[h][w]= (dp[h-1][w]%MOD+dp[h][w-1]%MOD)%MOD;
				
			else if(arr[h-1][w]=='.' && arr[h][w-1]=='#' && h-1>=0 && w-1>=0)
				dp[h][w]=dp[h-1][w]%MOD;
			
			else if(arr[h-1][w]=='#' && arr[h][w-1]=='.' && h-1>=0 && w-1>=0)
				dp[h][w]=dp[h][w-1]%MOD;
			
			else if(arr[h-1][w]=='.' && arr[h][w-1]=='.' && h-1>=0 && w-1>=0)
				dp[h][w]= (dp[h-1][w]%MOD+dp[h][w-1]%MOD)%MOD;
				
				
			else if(h==0 && w-1>=0 && arr[h][w]=='.'){
				dp[h][w]=dp[h][w-1]%MOD;
			}
			
			else if(h-1>=0 && w==0 && arr[h][w]=='.'){
				dp[h][w]=dp[h-1][w]%MOD;
			}
			else dp[h][w]=0;
			
		}
	
	}
	
	return dp[H-1][W-1];

}



//recursive solution
ll grid1( ll h, ll w, ll cols, char arr[][cols]){
	if(h<0||w<0) return 0;

	else if(h==0 && w==1 && arr[h][w]=='.')
		return 1;
	else if(h==0 && w==1 && arr[h][w]=='#')
		return 1;
		
	else if(h==1 && w==0 && arr[h][w]=='.')
		return 1;
		
	else if(h==1 && w==0 && arr[h][w]=='#')
		return 0;
		
	else if(arr[h-1][w]=='.' && arr[h][w-1]=='.' && h-1>=0 && w-1>=0)
		return ((grid1(h-1, w,cols, arr))%MOD+(grid1( h, w-1, cols, arr))%MOD)%MOD;
		
	else if(arr[h-1][w]=='.' && arr[h][w-1]=='#' && h-1>=0 && w-1>=0)
		return (grid1(h-1, w, cols, arr))%MOD;
	
	else if(arr[h-1][w]=='#' && arr[h][w-1]=='.' && h-1>=0 && w-1>=0)
		return (grid1(h, w-1, cols, arr))%MOD;
	
	else if(arr[h-1][w]=='.' && arr[h][w-1]=='.' && h-1>=0 && w-1>=0)
		return ((grid1(h-1, w,cols, arr))%MOD+(grid1( h, w-1, cols, arr))%MOD)%MOD;
		
		
	else if(h==0 && w-1>=0 && arr[h][w]=='.'){
		return (grid1( h, w-1, cols, arr))%MOD;
	}
	
	else if(h-1>=0 && w==0 && arr[h][w]=='.'){
		return (grid1( h-1, w, cols, arr))%MOD;
	}
	else return 0;
}

int main(){
	ll h, w,cols;
	scanf("%lld%lld", &h, &w);
	char arr[h][w];
	cols = w;
	ll i=0,j=0;
	char c;
	while(i<h){
		j=0;
		while(j<w){
			
			scanf("%c", &c);
			
			if(c!='\n'){
				arr[i][j]=c;
				j++;
			}
			
			
		}
		i++;
		
	}
			
	
			
	printf("%lld\n", grid1_dp( h, w,cols,  arr));
	

}

Compiler output:
a.cc:9:50: error: use of parameter outside function body before ']' token
    9 | ll grid1_dp( ll H, ll W, ll cols, char arr[][cols]){
      |                                                  ^
a.cc: In function 'll grid1_dp(...)':
a.cc:11:15: error: 'H' was not declared in this scope
   11 |         ll dp[H][W];
      |               ^
a.cc:11:18: error: 'W' was not declared in this scope
   11 |         ll dp[H][W];
      |                  ^
a.cc:16:38: error: 'dp' was not declared in this scope
   16 |                         if(h<0||w<0) dp[h][w]=0;
      |                                      ^~
a.cc:18:49: error: 'arr' was not declared in this scope
   18 |                         else if(h==0 && w==1 && arr[h][w]=='.')
      |                                                 ^~~
a.cc:19:33: error: 'dp' was not declared in this scope
   19 |                                 dp[h][w]=1;
      |                                 ^~
a.cc:21:33: error: 'dp' was not declared in this scope
   21 |                                 dp[h][w]=0;
      |                                 ^~
a.cc:24:33: error: 'dp' was not declared in this scope
   24 |                                 dp[h][w]=1;
      |                                 ^~
a.cc:27:33: error: 'dp' was not declared in this scope
   27 |                                 dp[h][w]=0;
      |                                 ^~
a.cc:30:33: error: 'dp' was not declared in this scope
   30 |                                 dp[h][w]= (dp[h-1][w]%MOD+dp[h][w-1]%MOD)%MOD;
      |                                 ^~
a.cc:33:33: error: 'dp' was not declared in this scope
   33 |                                 dp[h][w]=dp[h-1][w]%MOD;
      |                                 ^~
a.cc:36:33: error: 'dp' was not declared in this scope
   36 |                                 dp[h][w]=dp[h][w-1]%MOD;
      |                                 ^~
a.cc:39:33: error: 'dp' was not declared in this scope
   39 |                                 dp[h][w]= (dp[h-1][w]%MOD+dp[h][w-1]%MOD)%MOD;
      |                                 ^~
a.cc:43:33: error: 'dp' was not declared in this scope
   43 |                                 dp[h][w]=dp[h][w-1]%MOD;
      |                                 ^~
a.cc:47:33: error: 'dp' was not declared in this scope
   47 |                                 dp[h][w]=dp[h-1][w]%MOD;
      |                                 ^~
a.cc:49:30: error: 'dp' was not declared in this scope
   49 |                         else dp[h][w]=0;
      |                              ^~
a.cc:55:16: error: 'dp' was not declared in this scope
   55 |         return dp[H-1][W-1];
      |                ^~
a.cc: At global scope:
a.cc:62:47: error: use of parameter outside function body before ']' token
   62 | ll grid1( ll h, ll w, ll cols, char arr[][cols]){
      |                                               ^
a.cc: In function 'll grid1(...)':
a.cc:63:12: error: 'h' was not declared in this scope
   63 |         if(h<0||w<0) return 0;
      |            ^
a.cc:63:17: error: 'w' was not declared in this scope
   63 |         if(h<0||w<0) return 0;
      |                 ^
a.cc:65:33: error: 'arr' was not declared in this scope
   65 |         else if(h==0 && w==1 && arr[h][w]=='.')
      |                                 ^~~
a.cc:77:39: error: 'cols' was not declared in this scope
   77 |                 return ((grid1(h-1, w,cols, arr))%MOD+(grid1( h, w-1, cols, arr))%MOD)%MOD;
      |                                       ^~~~
a.cc:80:39: error: 'cols' was not declared in this scope
   80 |                 return (grid1(h-1, w, cols, arr))%MOD;
      |                                       ^~~~
a.cc:83:39: error: 'cols' was not declared in this scope
   83 |                 return (grid1(h, w-1, cols, arr))%MOD;
      |                                       ^~~~
a.cc:86:39: error: 'cols' was not declared in this scope
   86 |                 return ((grid1(h-1, w,cols, arr))%MOD+(grid1( h, w-1, cols, arr))%MOD)%MOD;
      |                                       ^~~~
a.cc:90:40: error: 'cols' was not declared in this scope
   90 |                 return (grid1( h, w-1, cols, arr))%MOD;
      |                                        ^~~~
a.cc:94:40: error: 'cols' was not declared in this scope
   94 |                 return (grid1( h-1, w, cols, arr))%MOD;
      |                                        ^~~~