how to code this for any user input ??
#include <bits/stdc++.h>
using namespace std ;
int main(){
int rw , cl ;
cout << "rows : " ;
cin >> rw ;
cout << "columns : " ;
cin >> cl ;
for (int a=1 ; a <= cl ; a++){
cout << "* " ;
}
cout << endl;
for (int b=1 ; b <= rw-2 ; b++ ){
cout << "* " ;
for (int c=1 ; c <= cl-2 ; cl++){
cout << " " ;
}
cout << "*" ;
cout << endl;
}
for (int d=1 ; d<= cl ; d++){
cout << "*" ;
}
return 0;
}
what’s the mistake in this???
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
for(int i = 0; i < n; i++){
for(int j = 0; j < n-i; j++){
cout << "* ";
}
cout << "\n";
}
return 0;
}
#include<stdio.h>
int main() {
int i,j;
for(i=1;i<=5;i++) {
for(j=1;j<=5;j++) {
if(j<=6-i)
printf("* “);
else
printf(” “);
}
printf(”\n");
}
return 0;
}
#include < iostream >
using namespace std;
int main()
{
int n,i;
cin>>n;
for(i=1;i<=n;i++)
{
for(int j=1;j<=n-i;j++)
{
cout<<"*";
}
cout<<"\n";
}
}
#include < iostream >
using namespace std;
int main()
{
int n,i;
cin>>n;
for(i=1;i<=n;i++)
{
for(int j=1;j<=(n+1)-i;j++)
{
cout<<"*";
}
cout<<"\n";
}
}