EmbLogic's Blog

Program in c to print sin wave.

#include<stdio.h>
#include<math.h>
int main()
{
double a,b,i;
int j;
int count=0;
a=22.0/7.0;
for(i=0.0; i <= 4.0; i+=0.1)
{
b= sin(a*i)+ cos(a*i);
if(b >= 0)
{
printf(”          “);
for(j =10*b;j >= 0.0; j-=1.0)
{
printf(” “);
}
}
if(b < 0.0)
{
for(j=10 +(10*b);j>=0.0;j-=1.0)
{
printf(” “);
}
}
printf(“*\n”);

}
return 0;
}

********************************************************************************************

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>