C - Show Trigonometry sin graph

Description

Show Trigonometry sin graph

Demo

#include <stdio.h> 
#include <math.h> 

#define PI 3.14159 //from w ww  . j  a  v a  2s. co m
#define WAVELENGTH 70 
#define PERIOD .1 

int main() 
{ 
    float graph,s,x; 

    for(graph=0;graph<PI;graph+=PERIOD) 
    { 
        s = sin(graph); 
        for(x=0;x<s*WAVELENGTH;x++) 
            putchar('*'); 
        putchar('\n'); 
    } 
    return(0); 
}

Result

Related Topic