Showing posts with label Filled. Show all posts
Showing posts with label Filled. Show all posts

Tuesday 13 August 2013

Rectangle

Rectangle


In this post of shapes in c, you will find the code to draw rectangle in C++ using "*".

CODE:

/*

 Join http://shapesinc.blogspot.com
 for more codes of shapes

*/
#include<iostream>
using namespace std;

int main()
{
cout << "Join http://shapesinc.blogspot.com
for more codes of shapes\n\n";
cout<<"CAUTION:   The input should not be other than numerical values \n\n\a";

int length=0, width=0;

cout << "Enter the length of the rectangle\n";
cin>>length;
cout << "Enter the width of the rectangle\n";
cin>>width;
for(int i=0; i<length; i++)
{
    for(int j=0; j<width; j++)
        cout << "*";
      cout<<endl;
}
}








Output:


Rectangle_Shapes_In_C

Hexagon

Hexagon

In this post of shapes in c, you will find the code to draw hexagon in C++ using "*". 

 Code:

copy the code from here.
/*         Join us at
 http://shapesinc.blogspot.com 
     for more codes of shapes  */
#include<iostream>
using namespace std;
int main()
{
cout << "Join http://shapesinc.blogspot.com for more codes of shapes\n\n";
 cout<<"CAUTION:   The input should not be other than numerical values \n\n\a";  
int length=0;
cout << "Enter the size of the hexagon\n";
cin>>length;
for(int i=0, k=length, l=2*length-1; i<length; i++, k--, l++)
{
for(int j=0; j<3*length; j++)
{
if(j>=k && j<=l)
cout << "*";
else
cout << " ";
}
cout<<endl;
}
for(int i=0; i<length; i++)
{
for(int j=0; j<3*length; j++)
cout << "*";
cout<<endl;
}
for(int i=0, k=1, l=3*length-2; i<length; i++, k++, l--)
{
for(int j=0; j<3*length; j++)
{
if(j>=k && j<=l)
cout << "*";
else
cout << " ";
}
cout<<endl;
}
}

Output:


Hexagon_Shapes_In_C

Right Angle Triangle 1

Right Angled Triangle in C++ 1:

In this post of shapes in c, you will find the code for constructing a top left right angled triangle in C++ using "*". 

For more visit: triangle programs in c.

Code:


Copy the code from here.
/*        Join us at
 http://shapesinc.blogspot.com    for more codes of shapes */
#include<iostream>
using namespace std;
int main()
{
cout << "Join http://shapesinc.blogspot.com for more codes of shapes\n\n";
int size=0;
cout << "Enter the size of the right angle triangle\n";
cin>>size;
for(int i=0; i<size; i++)
{
for(int j=i; j<size; j++)
cout << "*";
cout << endl;
}
}



Output:





Right_Angle_Triangle_Shapes_In_C


Monday 12 August 2013

Diamond Code

Diamond:

In this post of shapes in c, you will find the code of diamond problem in C++ using "*".

Code:

copy your code from below:
/* Join us at 
http://shapesinc.blogspot.com 
for more codes of shapes*/
#include<iostream>
using namespace std;
int main()
{
cout << "Join http://shapesinc.blogspot.com for more codes of shapes\n\n";
int length=0;
cout << "Enter the size of the Diamond\n";
cin>>length;
for(int i=length, k=0; i>=0; i--, k++)
{
for(int j=0; j<length+k; j++)
{
if(j>i)
cout << "*";
else
cout << " ";
}
cout<<endl;
}
for(int i=1, k=length; i<length; i++, k--)
{
for(int j=0; j<length+k-1; j++)
{
if(i<j)
cout << "*";
else
cout << " ";
}
cout<<endl;
}
}

Output:




Thursday 8 August 2013

Square

Square:

In this post of shapes in c, you will find the code for constructing a square in C++ using "*".

Code:

The code is as follows.
/*      Join us at 
 http://shapesinc.blogspot.com
 for more codes of shapes */
#include<iostream>
using namespace std;
int main()
{
cout << "Join http://shapesinc.blogspot.com for more codes of shapes\n\n";
int size=0;
cout << "Enter the size of the square\n";
cin>>size;
for(int i=0; i<size; i++)
{
for(int j=0; j<size; j++)
cout << "*";
cout<<endl;
}
}



Output: