C++: Program to print pattern

Q. Write a program to print the pattern
     
1
22
333
4444
55555
Ans.
#include <iostream>
using namespace std;
int main()
{
for(int i=1;i<=5;i++){
  for(int j=1;j<=i;j++){
    cout<<i;
  }
  cout<<endl;
}
return 0;
}
Any better solution or suggention is welcomed.
               < Happy Coding >
In Association with Amazon.in

Popular Posts

Top 10 Web Sites Every Programmer Should Visit Daily

What is "namespace" and why do we use it?