Showing posts with label Fan. Show all posts
Showing posts with label Fan. Show all posts

Tuesday 13 August 2013

Fan 2

Fan 2:

In this post of shapes in c you will be able to construct the code for a fan (Part 2) 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";
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++)
cout<<"  ";
for(int spaces=i ; spaces<=size ; spaces++)
{
if(i==0)
cout<<"* ";
else
if(spaces==i || spaces==size)
cout<<"* ";
else 
cout<<"  ";
}
for(int j=i ; j<size ; j++)
cout<<"  ";
for(int j=0; j<=i ; j++)
{
if(i==size)
cout<<"* ";
else 
if(j==0 || j==i)
cout<<"* ";
else 
cout<<"  ";
}
cout<<endl;
}
for(int m=0 ; m<=size ; m++)
{
for(int spaces1=m ; spaces1<=size ; spaces1++)
{
if (m==0)
cout<<"* ";
else
if(spaces1==m || spaces1==size)
cout<<"* ";
else
cout<<"  ";
}
for(int n=0; n<m ; n++)
cout<<"  ";
for(int spaces1=0 ; spaces1<=m ; spaces1++)
{
if(m==0 || m==size)
cout<<"* ";
else
if(spaces1==0 || spaces1==m)
cout<<"* ";
else 
cout<<"  ";
}
cout<<endl;
}
return 0;
}



Output:


Fan_In_Shapes_In_c




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





Moving Fan

Moving Fan:

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

Code:

#include<iostream>
#include<Windows.h>
using namespace std;
void fan1(const int size);
void fan2(const int size);
int main()
{
int size, time;
cout<< "Enter the size of fan" << endl;
cin>>size;
cout<< "For how many seconds you want to switch on the fan" << endl;
cin>>time;
system("cls");
for(int i=0 ; i<2*time ; i++)
{
fan1(size);
Sleep(500);
system("cls");
fan2(size);
Sleep(500);
system("cls");
}
return 0;
}
void fan1 (const int 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;
}
}
void fan2 (const int size)
{
for(int i=0 ; i<=size ; i++)
{
for(int j=0 ; j<i ; j++)
cout<<"  ";
for(int spaces=i ; spaces<=size ; spaces++)
{
if(i==0)
cout<<"* ";
else
if(spaces==i || spaces==size)
cout<<"* ";
else 
cout<<"  ";
}
for(int j=i ; j<size ; j++)
cout<<"  ";
for(int j=0; j<=i ; j++)
{
if(i==size)
cout<<"* ";
else 
if(j==0 || j==i)
cout<<"* ";
else 
cout<<"  ";
}
cout<<endl;
}
for(int m=0 ; m<=size ; m++)
{
for(int spaces1=m ; spaces1<=size ; spaces1++)
{
if (m==0)
cout<<"* ";
else
if(spaces1==m || spaces1==size)
cout<<"* ";
else
cout<<"  ";
}
for(int n=0; n<m ; n++)
cout<<"  ";
for(int spaces1=0 ; spaces1<=m ; spaces1++)
{
if(m==0 || m==size)
cout<<"* ";
else
if(spaces1==0 || spaces1==m)
cout<<"* ";
else 
cout<<"  ";
}
cout<<endl;
}
}