The following is the code, i have tried al the other styles mentioned in the comments one by one but none worked to remove the garbage value, Although "jugaad" works but it's not performance wise good. Couldn't figure out what's wrong !
#include <bits/stdc++.h>
using namespace std;
int main() {
int n,m;
cin>>n>>m;
// Other styles
// int data[n+1][m+1] = {0,0};
// int data[n+1][m+1] = {0};
// int data[n+1][m+1] = {{0,0}};
int data[n][m] = {0};
// Jugaad start:
for(int i=0;i<m;i++){
data[0][i] = 0;
}
// Jugaad end
cout<<"\n";
for(int x=0;x<n;x++){
for(int y=0;y<m;y++){
cout<<data[x][y]<<"\t";
}
cout<<"\n";
}
cout<<"\n";
return 0;
}