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
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;
}
3. (a) write a value-returning function with appropriate parameter(s) to do the following: the function recieves...
Can I see that source code in python Write the following value-returning function: encoded - Takes a string as parameter and returns the string with each vowel substituted by its corresponding number as follows: a -1 e-2 0-4 。u_5 The function MUST USE string slicing Write a main program that will take an input string (text) from command line and it will display the input text encoded. You will call the encoded function to get the text encoded.
(c++) (codeblocks) Write a program that contains a value-returning function that returns a value to be displayed in main() with the function call. No values are passed to the function. The function body should be written to generate a random number from 1-10 as its return value. Display with the call to function in main(): The function returned the value of <return value> when it was called in main.
Write a program that write a value-returning function, isVowel, that returns the value true if a given character is a vowel and otherwise returns false. You must insert the following comments at the beginning of your program and write our commands in the middle: Write a C++ Program: /* // Name: Your Name // ID: Your ID */ using namespace std; #include <iostream> using namespace std; bool isVowel(char ch); int main() { char ch; … … ...
Write a value-returning C++ function returns the average length of an array of strings. Name the function stringsAverageLength and use the following header: double stringsAverageLength(string array [], int n) { } where the parameter 'array' has 'n' strings and the return value is the average length of all of the strings in the array. For example, if the function is called like this: string cars[3] = { "Toyota", "Ford", "Tesla" }; cout << fixed << setprecision(2) << stringsAverageLength(cars, 3) <<...
c++ please (1) Write a program that prompts the user to enter an integer value N which will rpresent the parameter to be sent to a function. Use the format below. Then write a function named CubicRoot The function will receive the parameter N and return'its cubic value. In the main program print the message: (30 Points) Enter an integer N: [. ..1 The cubic root of I.. ] is 2 update the code om part and write another function...
6.3.7. Analog write and digital write methods Do this Similar to the ar and dr methods, write the methods aw and dw. Each of these methods has a pin number parameter and a value parameter. Write the value to the corresponding analog or digital pin instance. Just like ar and dr, write the value to the pin only if the pin number is in the correct 17 range. These functions do not need to retum anything. One other thing: in...
Write a program named program51.py that defines a value-returning function named cuber that returns both the surface area and volume of a cube. A cube is a rectangular prism with all sides equal. Prompt the user to enter the cube's side length from the keyboard in the main function and then call the cuber function. Moving forward for all assignments and for this program, all other code would be in a main function, called at the very end of your...
GPA calculator: Assume the user has a bunch of courses they took, and need to calculate the overall GPA. We will need to get the grade and number of units for each course. It is not ideal to ask how many courses they took, as they have to manually count their courses. Programming is about automation and not manual work. We will create a textual menu that shows 3 choices. 1. Enter course grade and units. 2. Show GPA. 3....
Write a C function that determines whether its parameter, which is an integer number has a specific mathematical characteristic. Then, call the function from inside a main function. The mathematical characteristic will be given to you (*), along with some examples. this is all that was given
C++ //get_letter_grade.h /* Write a function gpa_to_letter_grade that returns a string and accepts a double gpa parameter */ //get_letter_grade.cpp /* Write function code for gpa_to_letter_grade that returns a string and accepts a double gpa parameter YOU MUST USE A SWITCH STATEMENT Given a double 3.5 returns the string A TIP: You'll have to convert the double to an int using multiplication Table 3.5 to 4 returns an A 3.0 to 3.49 returns a B 1.7 to 2.99 returns a C...