/* --------------------------------------------------------------------- ** Figure 10.7: Subscript demo: The magnitude of a vector. ** --------------------------------------------------------------------- */ #include "tools.h" void main( void ) { double vec[3]; /* A vector in 3-space. */ double magnitude; puts( "\n Subscript Demo: The Magnitude of a Vector" ); printf( " Please enter the 3 components of a vector: " ); scanf( "%lg%lg%lg", &vec[0], &vec[1], &vec[2] ); magnitude = sqrt( vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2] ); printf( " The magnitude of vector ( %g, %g, %g ) is %g \n", vec[0], vec[1], vec[2], magnitude ); bye(); }