Forloop
Forloop
int main() {
// Outer loop for rows
for (int i = 1; i <= 5; i++) {
// Inner loop for columns
for (int j = 1; j <= 5; j++) {
cout << i * j << "\t"; // Print the product of i and j
}
cout << endl; // Move to the next line after each row
}
return 0;
}
Output.
1 2 3 4 5
2 4 6 8 10
3 6 9 12 15
4 8 12 16 20
5 10 15 20 25
#include <iostream>
using namespace std;
int main() {
// Number of rows
int rows = 5;
*
**
***
****
*****
#include <iostream>
using namespace std;
int main() {
int rows = 3, columns = 3;
int value = 1;
1 2 3
4 5 6
7 8 9
#include <iostream>
using namespace std;
int main() {
int rows = 5;
12345
1234
123
12
1
#include <iostream>
using namespace std;
int main() {
int rows = 3; // Number of rows in the pyramid
*
***
*****