Skip to content

Instantly share code, notes, and snippets.

@dhruvramani
Last active August 29, 2015 14:12
Show Gist options
  • Save dhruvramani/17ed6f6cddc8c92d20de to your computer and use it in GitHub Desktop.
Save dhruvramani/17ed6f6cddc8c92d20de to your computer and use it in GitHub Desktop.
A program to generate a Sin Graph
#include <iostream>
#include <math>
#define Length 75
int main()
{
char a[Length][Length];
for(int i=0;i<Length;i++)
for(int j=0;j<Length;j++)
a[i][j]=' ';
for(int i=0;i<Length;i++)
a[Length/2][i]='_';
int index=Length/2,angle=0,bo=1;
for(int i=0;i<Length;i++)
{
double k=sin(angle*M_PI/180.0);
if(bo==1)
if(k==1)
bo=0;
else
index--;
if(bo==0)
if(k==-1)
bo=1;
else
index++;
a[index][i]='.';
angle+=5;
}
for(int i=0;i<Length;i++)
{
for(int j=0;j<Length;j++)
cout<<a[i][j];
cout<<endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment