231k views
5 votes
Write a function that prompts the user to enter the speed of a vehicle. If speed is less than 20, display too slow; if speed is greater than 80, display too fast; otherwise, display just right

1 Answer

3 votes

The code of the given problem is given below :

#include<iostream>

using namespace std;

void print( float speed ){

if(speed < 20 )

{

cout<<"too slow\\";

}

else if(speed > 80 )

{

cout<<"too fast\\";

}

else{

cout<<"right\\";

}

}

int main()

{

print( 18.6 );

print( 45 );

print( 100 );

return 0;

}

User JCBrown
by
4.5k points