Showing posts with label Square. Show all posts
Showing posts with label Square. Show all posts

Tuesday, 13 August 2013

Hollow Square

Hollow Square

In this post of shapes in c, you will find the code for constructing a hollow square 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";
 cout<<"CAUTION:   The input should not be other than numerical values \n\n\a";  
int length=0;
cout << "Enter the length of the hollow square\n";
cin>>length;
for(int i=0; i<length; i++)
{
for(int j=0; j<length; j++)
{
if(i==0 || i==length-1 || j==0 || j==length-1)
cout << "*";
else
cout << " ";
}
cout<<endl;
}
}

Output:


Hollow_Square_Shapes_In_c


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: