int main() {
int i,j; cin>>i>>j;
while(i>0){ int k; j=k; while(k>0){
cout<<"*"; k--; } i--;
}return 0;
}
Asked by: Anonymous on May 13, 2022, 8:15 a.m. Last updated on May 13, 2022, 8:15 a.m.
Here is the correct and complete code. Can you try this? I hope it can fix the error you are getting.
using namespace std;
int main() { int i, j; cin >> i >> j;
while (i > 0) {
int k = j; // Initialize k with the value of j
while (k > 0) {
cout << "*";
k--;
}
i--;
cout << endl; // Add a newline after each inner loop
}
return 0;
}
Thanks
It should be k=j, instead of j=k. k was declared but now initialized so, it have large garbage value initially, and you wrote j=k. So every time k is having large garbage value, so its taking too much time
abhishekzobin02052000 last updated on May 16, 2022, 12:52 p.m.