Related questions
// Example
countLetters("hello") // returns 1
// Exercise 2
// ----------------------------------------------------------------
// Write a function that takes 2 arguments, both integers.
// It returns an array containing those numbers with all the integers between them.
// For this exercise you can assume that the first integer is strictly less than the second integer.
const countNumbers = (start, end) => {
// your code here...
}
// Exercise 3
// ----------------------------------------------------------------
// Write a function that takes 1 argument, a string.
// It returns true if the string is a palindrome (the same forwards and backwards).
// It returns false if the string is not a palindrome.
const isPalindrome = (string) => {
// your code here...
}
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 4 images
- > amount; 4 cout> amount; 11 cout << endl; 12 int numBills2 = (int) (amount / 20.0); 13 if (numBills2 * 20.0 < amount) { 14 numBills2++; 15} 16 cout << "John needs " << numBills1 << "bills" << endl; 17 cout << "Jane needs " << numBills2 << " bills" << endl; Function: Write a C++ function as described, not a complete program. ✔ Submitarrow_forwardP2 Wate a function called print_all that takes any number of scalar input argunents (the function does not need to check the format of the input) and prints them out one by one as illustrated by a few runs:> print_all () We received no numbers.> print_all(34) We received the following number: 34. » print_all (34, 56, 78, 90) We received the following numbers: 34, 56, 78, and 90. Make sure that the function handles the three cases (no input, one input, more than one input) correctly, as illustrated abovre The function has no output argumentsarrow_forwardCMPSC121: Intro to Programming Techniques gts Objectives After this lab assignment, students should be able to: • Write functions according to specified prototypes Instructions Define a function named reverse that: • Reverses the case of each letter in the first word of a string: o Lowercase letters become uppercase letters o Uppercase letters become lowercase letters • All other characters are left alone • You MUST use the following function prototype: string reverse (string); • HINT: you may use functions from the cetype library: isupper, islower, toupper, and tolower In the main function: • Ask the user to enter a sentence of their choice; the string may contain spaces • Use the reverse function to modify the user's string • Print the modificd string Sample Output Please enter a string below: McGyver premiered in 1985. Your modified string: MCGYVER premiered in 1985. Please enter a string below: Bedford-Stuyvesant, Brooklyn is called Bed-Stuy. Your modified string:...arrow_forward
- What is wrong with this code? # import random module import random #Main function def main(): # Initilize local variables randNumber=0 choice=1 while(choice>0): # Get a random number randNumber=random.randint(1,100) # Call the function to guess the number choice=GuessingGame(randNumber) #Print the statement print('Thanks for playing!') # Function definition def GuessingGame(num): # Get a value from the user guess=int(input('Enter a number between 1 and 100, or 0 to quit:')) # Do until value is greater than 0 while guess>0: if guess>num: # Print the statement print('Too high, try again') # Get a value from the user guess=int(input('Enter a number between 1 and 100,'\ 'or 0 to quit:')) elif guess<num: # Print the...arrow_forwardThank you soo much!arrow_forward60 points Write a function which takes one parameter int num, and prints out a countdown timer with minutes and seconds separated by a colon (:). It should print out one line for each second elapsed and then pause one second before printing out the next line. After it has done all of this, it should call a special function ringAlarm () to sound an alarm. A few things to note: - You can assume that calling the function sleepytime () makes the program pause for one second - You can assume that calling the function ringAlarm () makes the program sound an alarm - It should count down from num minutes:zero seconds to zero minutes:zero seconds - Your function must have the following signature: void timer (int num) You do not need to demonstrate calling this function from main(). You don't need to format the output nicely; the below is acceptable output for calling this function when num is 10: 10:0 9:59 9:58 //...and so on, all the way down to: 9:1 9:0 8:59 8:58 //..and so on, all the way...arrow_forward
- c++ If you pass a variable by ________________ to a function, the function will have access to the parameter’s original argument. Changes to the parameter are also made to the argument.arrow_forward//Test isEqual function cout << endl << "Testing isEqual function"; cout << endl << "------------------------" << endl; if (isEqual(s2, s3)) cout << "s2=\"" << s2 << "\" and s3=\"" << s3 << "\" are equal" << endl; else cout << "s2=\"" << s2 << "\" and s3=\"" << s3 << "\" are not equal" << endl; delete[] s3; s3 = getCopy(s2); if (isEqual(s2, s3)) cout << "s2=\"" << s2 << "\" and s3=\"" << s3 << "\" are equal" << endl; else cout << "s2=\"" << s2 << "\" and s3=\"" << s3 << "\" are not equal" << endl; bool isEqual(const charPtr s1, const charPtr s2){/*returns true if the cstring s1 is equal to the cstring s2Definition: Two c-strings s1 and s2 are equal if they have the same lengthand characters of s1 and s2 at corresponding indexes are the same.*/ }arrow_forwardParameters are the value passed to a function when the function is called and Argument are the variable defined in the function definition. True or falsearrow_forward
- Nested function classwork 2 Write 'taxIncome', a user-defined function that calculates income tax. y = taxIncome (income) defines the principal function. The main function calculates adjusted income as income - 6000. Then y = computeTax is called. For y = 0.28*AdjustedIncome, this function uses 'AdjustedIncome'. 'AdjustedIncome' was defined in the main function. Use 80,000ドル income.arrow_forwardwrite this using javascript arrow functionsarrow_forwardnumpy.ipynb 1. addToArray(i) def addToArray(i): # TO DO %time addToArr(10) 2. a function def findDriver(distanceArr, driversArr, customerArr): result = '' ### put your code here return result print(findDriver(locations, drivers, cust)) # this should return Clara 3. The Amazing 5D Music example array([[ 1, 3, -2, -4, -1], [ 0, -1, 1, -1, -2], [ 2, 3, -2, -3, -1], [ 1, -1, 0, -1, -3], [-2, -1, 1, -1, -3], [ 1, 3, -1, -2, -3]]) ``` # TODO array([11, 5, 11, 6, 8, 10]) # TODO array([1, 3, 4, 5, 0, 2]) # TODO # TODO def findClosest(customers, customerNames, x): # TO DO return '' print(findClosest(customers, customerNames, mikaela)) # Should print Ben print(findClosest(customers, customerNames, brandon)) # Should print Ann 4. Numpy drones arr = np.array([-1, 2, -3, 4]) arr2 = np.square(arr) arr2 locations = np.array([[4, 5], [6, 6], [3, 1], [9,5]]) drones = np.array(["wing_1a", "wing_2a",...arrow_forward
- Text book imageComputer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONText book imageComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceText book imageNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Text book imageConcepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningText book imagePrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationText book imageSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY