There will be differences in the if the condition of both the codes. so let us focus on that part of the code because the rest will be the same.
Rectangle:
No if condition is their.
for(int i=1;i<=row;i++){
for(int j=1;j<=col;j++){
cout<<"*";
}
cout<<endl;
}
Hollow rectangle:
for(int i=1;i<=row;i++){
for(int j=1;j<=col;j++){
if(i==1 || i==row || j==1 || j==col){
cout<<"*";
}
else{
cout<<" ";
}
}
cout<<endl;
}