Closed Thread
Results 1 to 5 of 5

Thread: sinusoidal function

  1. #1
    bekace is offline Newbie
    Join Date
    Jan 2010
    Posts
    13
    Rep Power
    0

    sinusoidal function

    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

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    PGP_Protector's Avatar
    PGP_Protector is offline Programming Professional
    Join Date
    Jun 2009
    Posts
    253
    Rep Power
    11

    Re: sinusoidal function

    # 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?

  4. #3
    bekace is offline Newbie
    Join Date
    Jan 2010
    Posts
    13
    Rep Power
    0

    Re: sinusoidal 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

  5. #4
    Join Date
    Sep 2009
    Location
    USA
    Posts
    3,400
    Blog Entries
    5
    Rep Power
    37

    Re: sinusoidal function

    Root Beer == System Administrator's Beer
    Download the new operating system programming kit! (some assembly required)

  6. #5
    bekace is offline Newbie
    Join Date
    Jan 2010
    Posts
    13
    Rep Power
    0

    Re: sinusoidal function

    Quote Originally Posted by Guest View Post
    thanks for the tutorial that helped much

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. function and function calls
    By jackson6612 in forum C and C++
    Replies: 10
    Last Post: 05-05-2011, 11:37 AM
  2. Replies: 1
    Last Post: 03-20-2011, 06:16 AM
  3. Replies: 3
    Last Post: 11-12-2010, 05:47 PM
  4. How do I use a variable in a function from a previous function?
    By system32 in forum JavaScript and CSS
    Replies: 2
    Last Post: 02-09-2010, 09:57 AM
  5. Need some help with a function
    By restin84 in forum C and C++
    Replies: 1
    Last Post: 04-12-2009, 06:38 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts