Solution for Exercise 8-14
ex0814
#include <stdio.h>
int main()
{
int coordinate;
printf("Input target coordinate: ");
scanf("%d",&coordinate);
if( coordinate >= -5 && coordinate <= 5 )
{
puts("Close enough!");
}
else
{
puts("Target is out of range!");
}
return(0);
}
Notes
* The comparison in Line 9 is inclusive because >= and <= are used. That means the range includes both -5 and 5. The exclusive equivalent would be:
* The else condition executes when variable coordinate is less than -5 or greater than 5. That's the opposite condition specified in Line 9.
Copyright © 1997-2025 by QPBC.
All rights reserved
