//c++ program to display a pattern like that
//so user only has to enter size
#include <iostream>
using namespace std;
int main()
{
int size; //declaring variable
cout<<"Enter size = "; //asking for input
cin>>size; //giving input(size)
if(size>0) // applying check
{
for(int i=1;i<=size;i++) //applying outer loop which will controll number of rows
{
for(int j=1;j<=i;j++) //applying inner loop whiuch will controll number of columns
{
cout<<j<<" ";
}
cout<<endl;
}
}
else
{
cout<<"You have enter wrong size\n"; //condition for invalid input
}
return 0;
}
//so user only has to enter size
#include <iostream>
using namespace std;
int main()
{
int size; //declaring variable
cout<<"Enter size = "; //asking for input
cin>>size; //giving input(size)
if(size>0) // applying check
{
for(int i=1;i<=size;i++) //applying outer loop which will controll number of rows
{
for(int j=1;j<=i;j++) //applying inner loop whiuch will controll number of columns
{
cout<<j<<" ";
}
cout<<endl;
}
}
else
{
cout<<"You have enter wrong size\n"; //condition for invalid input
}
return 0;
}
No comments:
Post a Comment