Tuesday, 14 June 2016

Right Triangle pattern using asterisks

Code:

#include<iostream>
using namespace std;
void main()
{
//Right Triangle pattern using asterisks
int square;
cout<<"Enter The Size of Square = "; // size
cin>>square;
for(int i = 1;i<=square;i++) // outer loop
{
for(int j=1;j<=i;j++) //inner loop
{
cout<<"*"; // value that is output
}
cout<<endl;//new line for next line output
}

}


Output

Wednesday, 8 June 2016

Right Triangle pattern using asterisks

Code:

#include<iostream>
using namespace std;
void main()
{
//Right Triangle pattern using asterisks
int square;
cout<<"Enter The Size of Square = "; // size
cin>>square;
for(int i = 1;i<=square;i++) // outer loop
{
for(int j=1;j<=i;j++) //inner loop
{
cout<<"*"; // value that is output
}
cout<<endl;//new line for next line output
}

}



Output

Square pattern using Numeric digit single inline in reverse order

Code:

#include<iostream>
using namespace std;
void main()
{
//Square pattern using Numeric digit single inline in reverse order
int square;
cout<<"Enter The Size of Square = "; // size
cin>>square;
for(int i = square;i>=1;i--) // outer loop
{
for(int j = square;j>=1;j--) //inner loop
{
cout<<i<<" "; // value that is output
}
cout<<endl;//new line for next line output
}

}


Output

Square pattern using Capital Alphabets in line

Code:

#include<iostream>
using namespace std;
void main()
{
//Square pattern using Capital Alphabets in line
int square;
cout<<"Enter The Size of Square = "; // size
cin>>square;
for(int i = 1;i<=square;i++) // outer loop
{
for(int j = 1;j<=square;j++) //inner loop
{
cout<<char(j+64)<<" "; // value that is output
}
cout<<endl;//new line for next line output
}

}


Output

Square pattern using Capital Alphabet single in line

Code:

#include<iostream>
using namespace std;
void main()
{
//Square pattern using Capital Alphabet single in line
int square;
cout<<"Enter The Size of Square = "; // size
cin>>square;
for(int i = 1;i<=square;i++) // outer loop
{
for(int j = 1;j<=square;j++) //inner loop
{
cout<<char(i+64)<<" "; // value that is output
}
cout<<endl;//new line for next line output
}

}


Output

Square pattern using Numeric digits in line

Code:

#include<iostream>
using namespace std;
void main()
{
//Square pattern using Numeric digits in line
int square;
cout<<"Enter The Size of Square = "; // size
cin>>square;
for(int i = 1;i<=square;i++) // outer loop
{
for(int j = 1;j<=square;j++) //inner loop
{
cout<<j<<" "; // value that is output
}
cout<<endl;//new line for next line output
}

}


Output

Square pattern using Numeric digit single in line

Code:

#include<iostream>
using namespace std;
void main()
{
//Square pattern using Numeric digit single in line
int square;
cout<<"Enter The Size of Square = "; // size
cin>>square;
for(int i = 1;i<=square;i++) // outer loop
{
for(int j = 1;j<=square;j++) //inner loop
{
cout<<i<<" "; // value that is output
}
cout<<endl;//new line for next line output
}

}


Output