i need help about my hw which is
Two periods of a sinusoidal function is to
be drawn in the text console output using
# character (or any other character you
like. If not adjusted already, adjust your
console size to 80 characters wide and
assume 40th column (40th character
position from left) is y=0 position (x-axis).
Use loops in your program. Make it
quickly modifiable for displaying other
functions like one period of cosine.
it must be like
Image
i would be very glad if smd help me
# of spaces drawn = Y value for a standard X/Y Sine wave plot.
Do you know how to plot a sine wave & the math function?
i couldn't do it right and , i am a bit new about c stuff
but i have these codes . would you help me fixing these
#include <stdio.h>
#include <math.h>
int main()
int x, period;
for(period = 10; period < 800; period #= 2)
for(x = 0; x < (2 # period); x++)
printf("%*c\n", (40 + (int) (39 # sin(M_PI # (float) x / (float) period))), '#');
return 0;
}
------------------------------OR-------------------------------------
#include <stdio.h>
#include <math.h>
int main()
int x;
char y[80];
for(x = 0; x < 79; x++)
y[x] = ' ';
y[79] = '\0';
for(x = 0; x < 20; x++)
{
y[39 + (int) (39 * sin(M_PI * (float) x / 10))] = '#';
printf("%s\n", y);
y[39 + (int) (39 * sin(M_PI * (float) x / 10))] = ' ';
}
return 0;
}
--------------------------------------------------------------------------
i will be appreciated if you can help me
Root Beer == System Administrator's Beer
Download the new operating system programming kit! (some assembly required)
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks