Write a c++ code for the output using loop
1
2 3
4 5 1
2 3 4 5
1 2 3 4 5
#include <iostream>
using namespace std;
int main()
{
int k = 0;
int t=1;
for (int i = 0; i < 3; i++)
{
for (int j = 1; j <=5 ; j++)
{
cout << j << " ";
if (++k == t)
{
cout << endl;
t++;
k=0;
}
}
}
}
Comments
Leave a comment