a4p4(introprog1620 perry)

a4p4(introprog1620 perry) - T = (randy()+1)*20; p =...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
#include <time.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #define pi 4*atan(1) double randy(void) { return rand()/(RAND_MAX + 1.0); /* 0 <= ret value <1.0*/ } int main(void) /* initialize variables */ {double y, A, w, T, n, p; int t; y = A*sin( w*t + p) + n; A = randy()+1; /* could this work? T= randy()+20 */
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: T = (randy()+1)*20; p = (randy())*pi; w = 2*pi/T; srand(time(0)); n = (randy()*.6*A)-.3*A; /* print columns of t and y */ printf(&quot; t y\n&quot;); /* for loop that goes from 0 to 100 with intervals of 1 */ for( t=0; t&lt;101; ++t) { /* prints t and y values in table */ printf(&quot;%4i %g\n&quot;, t, y); } return 0; }...
View Full Document

This note was uploaded on 04/08/2008 for the course ECE 1620 taught by Professor Perry during the Spring '08 term at Villanova.

Ask a homework question - tutors are online