The last row in this array of values is not coming out right.
Do you mind taking a look and letting me know what I'm missing?
Here is a screen cap of my output:
All of the other rows look fine.
This has been bugging me for a few hours, so any help will be awesome!
Code:
/* Header Files */
#include <stdio.h>
#include <math.h>
/*defined constants*/
#define max_column 5
#define max_row 5
#define Y .05
#define pi 3.14
#define d_zeta .05
#define d_k 50000
/*Start of main function*/
int main(void)
{
/* declarations: */
char c;
double zeta = .4, k, alpha, alpha_n, r, X, amp[max_column][max_row];
int column = 0, row, j, i;
/*Statements that perform the desired task*/
while(zeta <= .6)
{
row = 0;
k = 300000;
while(k <= 500000)
{
alpha = (2*pi*1.08);
alpha_n = sqrt(k / 1200.0);
r = alpha / alpha_n;
amp[column][row] = Y * sqrt((1 + ((2 * zeta * r) * (2 * zeta * r))) / (((1 - (r * r)) * (1 - (r * r)) + (( 2 * zeta * r) * (2 * zeta * r)))));
row ++;
k = k + d_k;
}
zeta = zeta + d_zeta;
column ++;
}
k = 300000;
/*Printing the results*/
printf("
Amplitude of Vibrations at 20 kph
");
printf("K\Damping Ratio| ");
zeta = .4;
while(zeta < .61)
{
printf("%0.2f ", zeta);
zeta += d_zeta;
}
printf("
________________________________________________________
");
for(row = 0; row < max_row; row++)
{
/*Print row label*/
printf(" %6.0f | ", k);
k += d_k;
/*Print the data*/
for( column = 0; column < max_column; column++)
{
printf("%0.4f ", amp[row][column]);
}
printf("
");
}
/*This keeps the window open*/
printf("
Press enter to q to quit.
");
do{
c = getchar();
}while( c != 'q' );
/*end the program*/
return 0;
}