Hello
First post so hoping you can help.
Having problems with a bit C coding.
Trying to return error when ever inserting a letter or nothing at all.
The code is below, looking for help with the bolded line.
ThanksCode:/******************************************************************************************************************* Author: Josh Brown Date: 28/2/09 Purpose: Speed Camera *******************************************************************************************************************/ #include <stdio.h> int main () { const int LIMIT = 59, MAX1 = 70, MAX2 = 90; int speed; /*Asks User for Speed*/ printf ("Please enter speed: "); scanf ("%d%*c", &speed); if (speed <= LIMIT) {printf("Not Speeding");} else if ( ( speed >= LIMIT ) && ( speed < MAX1 ) ) {printf("Speeding 1 to 10 Km/h over the limit. Fine is $80");} else if ( ( speed >= MAX1 ) && ( speed < MAX2 ) ) {printf("Speeding 11 to 30 Km/h over the limit. Fine is $150");} else if (speed >= MAX2) {printf("Speeding 30+ Km/h over the limit. Fine is $500");} else {printf("You did not enter a valid speed");}; return(0); } }
Josh


LinkBack URL
About LinkBacks
Reply With Quote
