Question

3. (a) write a value-returning function with appropriate parameter(s) to do the following: the function recieves...

3. (a) write a value-returning function with appropriate parameter(s) to do the following: the function recieves a number and determines whether the number is over 2.5. it return the number if the the number is over 2.5, otherwise return false.

(b) consider following : double gpq; cin >> gpa; write the code to call the function in (a) above to determine whether the number is over 2.5. if it is display a message indicating so, otherwise display a message "the number is not in range"

please answer separately part a and b, thanks

0 0
Add a comment Improve this question Transcribed image text
Answer #1

3(a). sol :

#include <iostream>
using namespace std;

double determine(double n) // Function which determines whether number is over 2.5
{
if(n>2.5)
return n;
else
return false;
}

3(b). sol :

#include <iostream>
using namespace std;

int main()
{
double gpq, o;
cout<<"enter the number"<<endl;
cin>>gpq;
o = determine(gpq); // calling the determine function to check whether number is greater than 2.5
if(o == gpq) // If o has the same value as gpq then it is in the range else it's not
cout<<"The number is over 2.5"<<endl;
else
cout<<"The number is not in the range"<<endl;
return 0;
}

Add a comment
Know the answer?
Add Answer to:
3. (a) write a value-returning function with appropriate parameter(s) to do the following: the function recieves...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT