Rotating circils program
This programs output shows circles.
Source code is given below. you can run this in any compiler to get the output.
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 printcircle(int r,int cx, int cy,char c)
{
double x,y;
x=0;
y=0;
for (double theta=0;theta<=360;theta+=0.25)
{
x=ceil(r*cos(theta*(3.14/180)) + cx);
y=ceil(r*sin(theta*(3.14/180)) + cy);
gotoRowCol(y,x);
cout<<c;
sleep(15);
}
}
int main()
{
int rows;
int cols;
int X=rows=50;
int Y=cols=50;
char c;
cout<<"Enter character of which you want to print circles: ";
cin>>c;
for(int r=5;r<=rows-1;r+=5)
{
printcircle(r,X,Y,c);
}
getch();
return 0;
}
Source code is given below. you can run this in any compiler to get the output.
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 printcircle(int r,int cx, int cy,char c)
{
double x,y;
x=0;
y=0;
for (double theta=0;theta<=360;theta+=0.25)
{
x=ceil(r*cos(theta*(3.14/180)) + cx);
y=ceil(r*sin(theta*(3.14/180)) + cy);
gotoRowCol(y,x);
cout<<c;
sleep(15);
}
}
int main()
{
int rows;
int cols;
int X=rows=50;
int Y=cols=50;
char c;
cout<<"Enter character of which you want to print circles: ";
cin>>c;
for(int r=5;r<=rows-1;r+=5)
{
printcircle(r,X,Y,c);
}
getch();
return 0;
}
Happy Reading!
No comments: