Write a fragment of code to: 1) input a floating point number. 2) use if stateme
ID: 3543281 • Letter: W
Question
Write a fragment of code to:1) input a floating point number.
2) use if statements to print an error if it above 100 or below 0.
3) cout appropriate message if the number is in AND an appropriate message if the number is out of the range. Write a fragment of code to:
1) input a floating point number.
2) use if statements to print an error if it above 100 or below 0.
3) cout appropriate message if the number is in AND an appropriate message if the number is out of the range.
Explanation / Answer
Here is how you would do it:
#include <iostream>
int main()
{
double N;
cin>>N;
if(N>100||N<0)cout<<"Error"<<endl;
else cout<<"Number is in range"<<endl;
}