Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Given the following constants and variable declarations .... #define PI 3.14159

ID: 3588193 • Letter: G

Question

Given the following constants and variable declarations

....

#define PI 3.14159

#define MAX 500

double len,count;

int step, size, val;

step = 3; size = 4; count = -1.0;

Explain the outcome of executing the following C statements given the constants and

initializations shown above. Give the resulting values where possible and provide an

explanation for any statements that give errors or compute values that may not be what

was intended.

• val = step % size;

• val = (450 - MAX)/ step;

• len = PI * count;

• len = step/size;

• val = size/0;

• val = step % (470-MAX);

• len = size/count;

• val = PI * step;

• val = step % (MAX - 480) ;

• len = (double) step/size;

Explanation / Answer

#include #include // Finds max in the array double maxArray( const float numbers[ ], int arraySize ); int main( void ) { double array1[ ] = { 10.0, 20.0, 100.0, 0.001 }; double array2[ 2 ][ 3 ] = { { 5.0, 10.0, 20.0 }, { 8.0, 15.0, 42.0 } }; int sizes[ 2 ] = { 4, 3 }; double max1, max2, max3, max4, max5; max1 = maxArray( array1, 4 ); max2 = maxArray( array1, sizes[ 0 ] ); max3 = maxArray( array2[ 1 ], 3 ); // Advanced max4 = maxArray( array2[ 0 ], 6 ); // Very Advanced max5 = maxArray( array1, -4 ); // Generates an error - returns 0.0; printf( "Maximums are %f, %f, %f, %f, and %f ", max1, max2, max3, max4, max5 ); return 0; } double maxArray( const double numbers[ ], int arraySize ) { /* Function to find the maximum in an array of doubles Note the use of the keyword "const" to prevent changing array data */ int i; double max; if( arraySize
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote