-
sine graph on C
firstly thanks all persons who posts this messages. If I don't look these posts ı cannot finish that project. By the way I was also one try to solve this question. now in my opinion my own sine program with true values works. Of course it is inexperinced program nevertheless ı want to thank other person who post and share my program.
this is my sine program;
#include<stdio.h>
#include<math.h>
#define PI 3.14
void main()
{
int step_size, line, delta; // step size in degree, numbers of lines, magnified and rolled degree in order to make usable
int count, co, cor; // counters
double rad; //degree converted from radian
// take number of line and step size from user
printf("Enter step size in degree>");
scanf("%d", &step_size);
printf("Enter how many lines you want>");
scanf("%d", &line);
// initialize count and cor
count = 0;
cor = 0;
//plot the sine graph in given step size in degree and line
while(count < line) {
//find sine of cor (in radian) and magnify in order to make usable
rad = cor * PI / 180.0;
delta = 50 * sin(rad) + 0.5;
//determine if sine of cor is positive or negative
if(delta >= 0) {
// for positive sine angles slide graph to right for negative angles
printf(" ");
co = 0;
// arrange spaces and asteriks
while(co < delta) {
printf(" ");
co++; }
printf("*\n"); }
else {
//arrange spaces and asteriks
co = -50;
while(co < delta) {
printf(" ");
co++; }
printf("*\n"); }
count++;
cor += step_size;
}
}
-
Yet another bump of a thread already dug up from the graveyard.
And yet again, no flippin' code tags either.
Closed.