Rotating Fan Program
Rotaing amezing program coded by me. Just for fun. Very interesting program Try it. Run it and enjoy.
Programming is game, Play with it. :)
Source Code:
#include <iostream>
#include<windows.h>
#include<conio.h>
#include <math.h>
using namespace std;
void sleep(int m)
{
for(int j=0;j<m*21000;j++)
{
}
}
void gotoRowCol(int rpos, int cpos)
{
int xpos=cpos, ypos = rpos;
COORD scrn;
HANDLE hOuput = GetStdHandle(STD_OUTPUT_HANDLE);
scrn.X = xpos; scrn.Y = ypos;
SetConsoleCursorPosition(hOuput,scrn);
}
void Fan(int x, char v)
{
gotoRowCol(10,5);
for(int i=9;i<=18;i++)
{
gotoRowCol(i,15);
cout<<v;
}
double z = 14;
double j = 10;
for(j=8 , z=14;j<20 , z<40;j++ , z+=2.5)
{
gotoRowCol(j+1,z+1);
cout<<v;
}
double a=20;
double b=14.5;
for(a=20 , b=14.5;a>=10 , b<40;a-- , b+=2.5)
{
gotoRowCol(a-1,b+1);
cout<<v;
}
for(int c=9;c<=18;c++)
{
gotoRowCol(c,40);
cout<<v;
}
}
void Fan1(int y, char c)
{
for(int q=23;q<=33;q++)
{
gotoRowCol(3,q);
cout<<c;
}
for(int w=23;w<=33;w++)
{
gotoRowCol(25,w);
cout<<c;
}
double r;
double t;
for(r=22,t=3;r<32,t<=26;r++,t+=2.2)
{
gotoRowCol(t+1,r+1);
cout<<c;
}
double p;
double k;
for(p=3 , k=32;p<26 , k>21;p++ , k-=0.5)
{
gotoRowCol(p+1,k+1);
cout<<c;
}
}
int main()
{
int x;
int rows=50;
int cols=40;
char c;
cout<<"Enter a character: ";
cin>>c;
while(true)
{
gotoRowCol(rows/2,cols/2);
{
Fan(x,c);
sleep(2000);
Fan(x,' ');
Fan1(x,c);
sleep(2000);
Fan1(x,' ');
}
}
}
Programming is game, Play with it. :)
Source Code:
#include <iostream>
#include<windows.h>
#include<conio.h>
#include <math.h>
using namespace std;
void sleep(int m)
{
for(int j=0;j<m*21000;j++)
{
}
}
void gotoRowCol(int rpos, int cpos)
{
int xpos=cpos, ypos = rpos;
COORD scrn;
HANDLE hOuput = GetStdHandle(STD_OUTPUT_HANDLE);
scrn.X = xpos; scrn.Y = ypos;
SetConsoleCursorPosition(hOuput,scrn);
}
void Fan(int x, char v)
{
gotoRowCol(10,5);
for(int i=9;i<=18;i++)
{
gotoRowCol(i,15);
cout<<v;
}
double z = 14;
double j = 10;
for(j=8 , z=14;j<20 , z<40;j++ , z+=2.5)
{
gotoRowCol(j+1,z+1);
cout<<v;
}
double a=20;
double b=14.5;
for(a=20 , b=14.5;a>=10 , b<40;a-- , b+=2.5)
{
gotoRowCol(a-1,b+1);
cout<<v;
}
for(int c=9;c<=18;c++)
{
gotoRowCol(c,40);
cout<<v;
}
}
void Fan1(int y, char c)
{
for(int q=23;q<=33;q++)
{
gotoRowCol(3,q);
cout<<c;
}
for(int w=23;w<=33;w++)
{
gotoRowCol(25,w);
cout<<c;
}
double r;
double t;
for(r=22,t=3;r<32,t<=26;r++,t+=2.2)
{
gotoRowCol(t+1,r+1);
cout<<c;
}
double p;
double k;
for(p=3 , k=32;p<26 , k>21;p++ , k-=0.5)
{
gotoRowCol(p+1,k+1);
cout<<c;
}
}
int main()
{
int x;
int rows=50;
int cols=40;
char c;
cout<<"Enter a character: ";
cin>>c;
while(true)
{
gotoRowCol(rows/2,cols/2);
{
Fan(x,c);
sleep(2000);
Fan(x,' ');
Fan1(x,c);
sleep(2000);
Fan1(x,' ');
}
}
}
Happy Reading!
No comments: