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<< "* ";elsecout<<" ";}else if (i==size )cout<< "* ";}for(int spaces=i ; spaces<size ; spaces++)cout<<" ";for(int j=i ; j<=size ; j++){if(i==0)cout<< "* ";elseif(j==i || j==size)cout<<"* ";elsecout<<" ";}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<<"* ";elseif(n==0 || n==m)cout<<"* ";elsecout<<" ";}for(int spaces1=0 ; spaces1<m ; spaces1++)cout<<" ";for(int n=m; n<=size; n++){if(m==0)cout<<"* ";elseif(n==m || n==size)cout<<"* ";elsecout<<" ";}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<<"* ";elseif(spaces==i || spaces==size)cout<<"* ";elsecout<<" ";}for(int j=i ; j<size ; j++)cout<<" ";for(int j=0; j<=i ; j++){if(i==size)cout<<"* ";elseif(j==0 || j==i)cout<<"* ";elsecout<<" ";}cout<<endl;}for(int m=0 ; m<=size ; m++){for(int spaces1=m ; spaces1<=size ; spaces1++){if (m==0)cout<<"* ";elseif(spaces1==m || spaces1==size)cout<<"* ";elsecout<<" ";}for(int n=0; n<m ; n++)cout<<" ";for(int spaces1=0 ; spaces1<=m ; spaces1++){if(m==0 || m==size)cout<<"* ";elseif(spaces1==0 || spaces1==m)cout<<"* ";elsecout<<" ";}cout<<endl;}}