/*
Q. Write a C++ program to print the following output using for loop.
1
2 2
3 3 3
4 4 4 4
*/
#include<iostream>
using namespace std;
main()
{
int i,j,n;
cout<<"\nEnter line number=";
cin>>n;
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
cout<<i<<" ";
}
cout<<"\n";
}
}
Q. Write a C++ program to print the following output using for loop.
1
2 2
3 3 3
4 4 4 4
*/
#include<iostream>
using namespace std;
main()
{
int i,j,n;
cout<<"\nEnter line number=";
cin>>n;
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
cout<<i<<" ";
}
cout<<"\n";
}
}
No comments:
Post a Comment