Printing patterns using 'for' loops in C++
#include <iostream>
using namespace std;
int main ()
{
for (int i=0;i<=10;i++)//No.of rows
{
for (int j=0;j<=10;j++)// No. of columns
{
cout<<"*";
}
cout<<endl;
}
return 0;
}
#include <iostream>
using namespace std;
int main ()
{
for (int i=0;i<=10;i++)
{
for (int j=0;j<=i;j++)
{
cout<<"*";
}
cout<<endl;
}
return 0;
}
}
#include <iostream>
using namespace std;
int main ()
{
for (int i=10;i>=0;i--)
{
for (int j=0;j<=i;j++)
{
cout<<"*";
}
cout<<endl;
}
return 0;
}
#include <iostream>
using namespace std;
int main ()
{
for(int i=0;i<=10;i++)
{
for(int j=0;j<i;j++)
{
cout<<" ";
}
for(int k=10;k>i;k--)
{
cout<<"*";
}
cout<<endl;
}
return 0;
}
using namespace std;
int main ()
{
for(int i=0;i<=10;i++)
{
for(int k=10;k>i;k--)
{
cout<<" ";
}
for(int j=0;j<i;j++)
{
cout<<"*";
}
cout<<endl;
}
return 0;
}
#include <iostream>
using namespace std;
int main ()
{
for(int i=0;i<=10;i++)
{
for(int k=10;k>i;k--)
{
cout<<" ";
}
for(int j=0;j<=i*2;j++)
{
cout<<"*";
}
cout<<endl;
}
return 0;
}
#include <iostream>
using namespace std;
int main ()
{
int l=9;
for(int i=1;i<=5;i++)
{
for(int k=0;k<l;k++)
{
cout<<"*";
}
cout<<endl;
for(int j=0;j<i;j++)
{
cout<<" ";
}
l=l-2;
}
return 0;
}
}
Comments
Post a Comment