Tuesday 13 August 2013

Fan 1

Fan 1:

In this post of shapes in c you will be able to construct the code for a fan (Part1) in C++ using "*".

Code:

/*              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 size;
cout << "Enter the size of fan" << endl;
cin>>size;
for(int i=0 ; i<=size ; i++)
{
for(int j=0 ; j<=i ; j++)
{
if(i!=size)
{
if(j==0 || j==i)
cout<< "* ";
else
cout<<"  ";
}
else if (i==size )
cout<< "* ";
}
for(int spaces=i ; spaces<size ; spaces++)
cout<<"  ";
for(int j=i ; j<=size ; j++)
{
if(i==0)
cout<< "* ";
else 
if(j==i || j==size)
cout<<"* ";
else
cout<<"  ";
}
cout<<endl;
}
for(int m=0 ; m<=size ; m++)
{
for(int spaces1=m ; spaces1<size ; spaces1++)
cout<<"  ";
for(int n=0; n<=m ; n++)
{
if(m==size)
cout<<"* ";
else 
if(n==0 || n==m)
cout<<"* ";
else 
cout<<"  ";
}
for(int spaces1=0 ; spaces1<m ; spaces1++)
cout<<"  ";
for(int n=m; n<=size; n++)
{
if(m==0)
cout<<"* ";
else
if(n==m || n==size)
cout<<"* ";
else 
cout<<"  ";
}
cout<<endl;
}
return 0;
}



Output:










Fan_In_Shapes_In_C





0 comments:

Post a Comment